Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protocols: do not capture cursor in hyprland-toplevel-export without pointer focus #9042

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/protocols/ToplevelExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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();
}
Expand Down
7 changes: 4 additions & 3 deletions src/protocols/ToplevelExport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class CToplevelExportFrame {
SP<CHyprlandToplevelExportFrameV1> resource;

PHLWINDOW pWindow;
bool overlayCursor = false;
bool ignoreDamage = false;
bool lockedSWCursors = false;
bool cursorOverlayRequested = false;
bool ignoreDamage = false;
bool lockedSWCursors = false;

WP<IHLBuffer> buffer;
bool bufferDMA = false;
Expand All @@ -66,6 +66,7 @@ class CToplevelExportFrame {
bool copyDmabuf(timespec* now);
bool copyShm(timespec* now);
void share();
bool shouldOverlayCursor() const;

friend class CToplevelExportProtocol;
};
Expand Down
Loading