diff options
| author | outfoxxed <outfoxxed@outfoxxed.me> | 2025-01-12 09:09:02 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-12 17:09:02 +0000 |
| commit | 4f0f512cab5a8052c80b365449b69b953a97e169 (patch) | |
| tree | e50c91f7de4acd874ce634df925d40b5a8170814 /src/protocols/ToplevelExport.cpp | |
| parent | a3a74993173662c06025ca633faa68b5590e2c5b (diff) | |
protocols: do not capture cursor in toplevel without pointer focus (#9042)
Diffstat (limited to 'src/protocols/ToplevelExport.cpp')
| -rw-r--r-- | src/protocols/ToplevelExport.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/protocols/ToplevelExport.cpp b/src/protocols/ToplevelExport.cpp index 2c934b40..68561533 100644 --- a/src/protocols/ToplevelExport.cpp +++ b/src/protocols/ToplevelExport.cpp @@ -2,6 +2,7 @@ #include "../Compositor.hpp" #include "ForeignToplevelWlr.hpp" #include "../managers/PointerManager.hpp" +#include "../managers/SeatManager.hpp" #include "types/WLBuffer.hpp" #include "types/Buffer.hpp" #include "../helpers/Format.hpp" @@ -77,7 +78,7 @@ CToplevelExportFrame::CToplevelExportFrame(SP<CHyprlandToplevelExportFrameV1> re if (!good()) return; - overlayCursor = !!overlayCursor_; + cursorOverlayRequested = !!overlayCursor_; if (!pWindow) { LOGM(ERR, "Client requested sharing of window handle {:x} which does not exist!", pWindow); @@ -247,6 +248,8 @@ bool CToplevelExportFrame::copyShm(timespec* now) { CFramebuffer outFB; outFB.alloc(PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y, PMONITOR->output->state->state().drmFormat); + auto overlayCursor = shouldOverlayCursor(); + if (overlayCursor) { g_pPointerManager->lockSoftwareForMonitor(PMONITOR->self.lock()); g_pPointerManager->damageCursor(PMONITOR->self.lock()); @@ -300,6 +303,8 @@ bool CToplevelExportFrame::copyDmabuf(timespec* now) { CRegion fakeDamage{0, 0, INT16_MAX, INT16_MAX}; + auto overlayCursor = shouldOverlayCursor(); + if (overlayCursor) { g_pPointerManager->lockSoftwareForMonitor(PMONITOR->self.lock()); g_pPointerManager->damageCursor(PMONITOR->self.lock()); @@ -328,6 +333,20 @@ bool CToplevelExportFrame::copyDmabuf(timespec* now) { return true; } +bool CToplevelExportFrame::shouldOverlayCursor() const { + if (!cursorOverlayRequested) + return false; + + auto pointerSurfaceResource = g_pSeatManager->state.pointerFocus.lock(); + + if (!pointerSurfaceResource) + return false; + + auto pointerSurface = CWLSurface::fromResource(pointerSurfaceResource); + + return pointerSurface && pointerSurface->getWindow() == pWindow; +} + bool CToplevelExportFrame::good() { return resource->resource(); } |
