mirror of
https://github.com/hyprwm/Hyprland
synced 2025-01-24 01:29:49 +01:00
protocols: do not capture cursor in toplevel without pointer focus (#9042)
This commit is contained in:
parent
a3a7499317
commit
4f0f512cab
2 changed files with 24 additions and 4 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include "../Compositor.hpp"
|
#include "../Compositor.hpp"
|
||||||
#include "ForeignToplevelWlr.hpp"
|
#include "ForeignToplevelWlr.hpp"
|
||||||
#include "../managers/PointerManager.hpp"
|
#include "../managers/PointerManager.hpp"
|
||||||
|
#include "../managers/SeatManager.hpp"
|
||||||
#include "types/WLBuffer.hpp"
|
#include "types/WLBuffer.hpp"
|
||||||
#include "types/Buffer.hpp"
|
#include "types/Buffer.hpp"
|
||||||
#include "../helpers/Format.hpp"
|
#include "../helpers/Format.hpp"
|
||||||
|
@ -77,7 +78,7 @@ CToplevelExportFrame::CToplevelExportFrame(SP<CHyprlandToplevelExportFrameV1> re
|
||||||
if (!good())
|
if (!good())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
overlayCursor = !!overlayCursor_;
|
cursorOverlayRequested = !!overlayCursor_;
|
||||||
|
|
||||||
if (!pWindow) {
|
if (!pWindow) {
|
||||||
LOGM(ERR, "Client requested sharing of window handle {:x} which does not exist!", 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;
|
CFramebuffer outFB;
|
||||||
outFB.alloc(PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y, PMONITOR->output->state->state().drmFormat);
|
outFB.alloc(PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y, PMONITOR->output->state->state().drmFormat);
|
||||||
|
|
||||||
|
auto overlayCursor = shouldOverlayCursor();
|
||||||
|
|
||||||
if (overlayCursor) {
|
if (overlayCursor) {
|
||||||
g_pPointerManager->lockSoftwareForMonitor(PMONITOR->self.lock());
|
g_pPointerManager->lockSoftwareForMonitor(PMONITOR->self.lock());
|
||||||
g_pPointerManager->damageCursor(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};
|
CRegion fakeDamage{0, 0, INT16_MAX, INT16_MAX};
|
||||||
|
|
||||||
|
auto overlayCursor = shouldOverlayCursor();
|
||||||
|
|
||||||
if (overlayCursor) {
|
if (overlayCursor) {
|
||||||
g_pPointerManager->lockSoftwareForMonitor(PMONITOR->self.lock());
|
g_pPointerManager->lockSoftwareForMonitor(PMONITOR->self.lock());
|
||||||
g_pPointerManager->damageCursor(PMONITOR->self.lock());
|
g_pPointerManager->damageCursor(PMONITOR->self.lock());
|
||||||
|
@ -328,6 +333,20 @@ bool CToplevelExportFrame::copyDmabuf(timespec* now) {
|
||||||
return true;
|
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() {
|
bool CToplevelExportFrame::good() {
|
||||||
return resource->resource();
|
return resource->resource();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,9 +51,9 @@ class CToplevelExportFrame {
|
||||||
SP<CHyprlandToplevelExportFrameV1> resource;
|
SP<CHyprlandToplevelExportFrameV1> resource;
|
||||||
|
|
||||||
PHLWINDOW pWindow;
|
PHLWINDOW pWindow;
|
||||||
bool overlayCursor = false;
|
bool cursorOverlayRequested = false;
|
||||||
bool ignoreDamage = false;
|
bool ignoreDamage = false;
|
||||||
bool lockedSWCursors = false;
|
bool lockedSWCursors = false;
|
||||||
|
|
||||||
WP<IHLBuffer> buffer;
|
WP<IHLBuffer> buffer;
|
||||||
bool bufferDMA = false;
|
bool bufferDMA = false;
|
||||||
|
@ -66,6 +66,7 @@ class CToplevelExportFrame {
|
||||||
bool copyDmabuf(timespec* now);
|
bool copyDmabuf(timespec* now);
|
||||||
bool copyShm(timespec* now);
|
bool copyShm(timespec* now);
|
||||||
void share();
|
void share();
|
||||||
|
bool shouldOverlayCursor() const;
|
||||||
|
|
||||||
friend class CToplevelExportProtocol;
|
friend class CToplevelExportProtocol;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue