Skip to content

Commit 1309b59

Browse files
committed
monitor: report a scheduled frame when tearing on cursor move
1 parent fb36815 commit 1309b59

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/helpers/Monitor.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,24 @@ void CMonitor::onMonitorFrame() {
14411441
g_pHyprRenderer->renderMonitor(self.lock());
14421442
}
14431443

1444+
void CMonitor::onCursorMovedOnMonitor() {
1445+
if (!tearingState.activelyTearing || !solitaryClient || !g_pHyprRenderer->shouldRenderCursor())
1446+
return;
1447+
1448+
// submit a frame immediately. This will only update the cursor pos.
1449+
// output->state->setBuffer(output->state->state().buffer);
1450+
// output->state->addDamage(CRegion{});
1451+
// output->state->setPresentationMode(Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_IMMEDIATE);
1452+
// if (!output->commit())
1453+
// Debug::log(ERR, "onCursorMovedOnMonitor: tearing and wanted to update cursor, failed.");
1454+
1455+
// FIXME: try to do the above. We currently can't just render because drm is a fucking bitch
1456+
// and throws a "nO pRoP cAn Be ChAnGeD dUrInG AsYnC fLiP" on crtc_x
1457+
// this will throw too but fix it if we use sw cursors
1458+
1459+
tearingState.frameScheduledWhileBusy = true;
1460+
}
1461+
14441462
CMonitorState::CMonitorState(CMonitor* owner) : m_pOwner(owner) {
14451463
;
14461464
}

src/helpers/Monitor.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ class CMonitor {
186186
void scheduleDone();
187187
bool attemptDirectScanout();
188188
void setCTM(const Mat3x3& ctm);
189+
void onCursorMovedOnMonitor();
189190

190191
void debugLastPresentation(const std::string& message);
191192
void onMonitorFrame();

src/managers/PointerManager.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include <cstring>
1818
#include <gbm.h>
1919
#include <cairo/cairo.h>
20+
#include <hyprutils/utils/ScopeGuard.hpp>
21+
22+
using namespace Hyprutils::Utils;
2023

2124
CPointerManager::CPointerManager() {
2225
hooks.monitorAdded = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any data) {
@@ -310,7 +313,12 @@ void CPointerManager::onCursorMoved() {
310313
recalc = true;
311314
}
312315

313-
if (state->hardwareFailed || !state->entered)
316+
if (!state->entered)
317+
continue;
318+
319+
CScopeGuard x([m] { m->onCursorMovedOnMonitor(); });
320+
321+
if (state->hardwareFailed)
314322
continue;
315323

316324
const auto CURSORPOS = getCursorPosForMonitor(m);

0 commit comments

Comments
 (0)