From 1309b59f2cb5179a4c59c111c35c7feede535eb6 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 15 Feb 2025 00:18:43 +0000 Subject: [PATCH] monitor: report a scheduled frame when tearing on cursor move --- src/helpers/Monitor.cpp | 18 ++++++++++++++++++ src/helpers/Monitor.hpp | 1 + src/managers/PointerManager.cpp | 10 +++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index fead5db94..24db3ea4b 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -1441,6 +1441,24 @@ void CMonitor::onMonitorFrame() { g_pHyprRenderer->renderMonitor(self.lock()); } +void CMonitor::onCursorMovedOnMonitor() { + if (!tearingState.activelyTearing || !solitaryClient || !g_pHyprRenderer->shouldRenderCursor()) + return; + + // submit a frame immediately. This will only update the cursor pos. + // output->state->setBuffer(output->state->state().buffer); + // output->state->addDamage(CRegion{}); + // output->state->setPresentationMode(Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_IMMEDIATE); + // if (!output->commit()) + // Debug::log(ERR, "onCursorMovedOnMonitor: tearing and wanted to update cursor, failed."); + + // FIXME: try to do the above. We currently can't just render because drm is a fucking bitch + // and throws a "nO pRoP cAn Be ChAnGeD dUrInG AsYnC fLiP" on crtc_x + // this will throw too but fix it if we use sw cursors + + tearingState.frameScheduledWhileBusy = true; +} + CMonitorState::CMonitorState(CMonitor* owner) : m_pOwner(owner) { ; } diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index c67bccc52..690b8c4a6 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -186,6 +186,7 @@ class CMonitor { void scheduleDone(); bool attemptDirectScanout(); void setCTM(const Mat3x3& ctm); + void onCursorMovedOnMonitor(); void debugLastPresentation(const std::string& message); void onMonitorFrame(); diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index 1c8e9976e..24f2b35dc 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -17,6 +17,9 @@ #include #include #include +#include + +using namespace Hyprutils::Utils; CPointerManager::CPointerManager() { hooks.monitorAdded = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any data) { @@ -310,7 +313,12 @@ void CPointerManager::onCursorMoved() { recalc = true; } - if (state->hardwareFailed || !state->entered) + if (!state->entered) + continue; + + CScopeGuard x([m] { m->onCursorMovedOnMonitor(); }); + + if (state->hardwareFailed) continue; const auto CURSORPOS = getCursorPosForMonitor(m);