[client] wayland: restore cursor warp support via pointer confining

This notably does not restore any of the cursed pointer confining logic.
This commit is contained in:
Quantum
2026-08-08 14:49:45 -04:00
committed by Geoffrey McRae
parent 70ae98491d
commit e2be90e264
3 changed files with 58 additions and 4 deletions

View File

@@ -670,9 +670,54 @@ void waylandUngrabKeyboard(void)
void waylandWarpPointer(int x, int y, bool exiting) void waylandWarpPointer(int x, int y, bool exiting)
{ {
(void)x; const int reqX = x;
(void)y; const int reqY = y;
(void)exiting; if (!wlWm.pointerInSurface)
{
MTRACE("warp drop=surface target=%d,%d exit=%d", x, y, exiting);
return;
}
if (wlWm.lockedPointer)
{
MTRACE("warp drop=lock target=%d,%d exit=%d", x, y, exiting);
return;
}
LG_LOCK(wlWm.surfaceLock);
if (wlWm.lockedPointer)
{
LG_UNLOCK(wlWm.surfaceLock);
MTRACE("warp drop=lock-race target=%d,%d exit=%d", x, y, exiting);
return;
}
int width, height;
wlWm.desktop->getSize(&width, &height);
if (x < 0) x = 0;
else if (x >= width) x = width - 1;
if (y < 0) y = 0;
else if (y >= height) y = height - 1;
struct wl_region * region = wl_compositor_create_region(wlWm.compositor);
wl_region_add(region, x, y, 1, 1);
struct zwp_confined_pointer_v1 * confine = zwp_pointer_constraints_v1_confine_pointer(
wlWm.pointerConstraints, wlWm.surface, wlWm.pointer, region,
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
uint32_t tempId = proxyId(confine);
wl_surface_commit(wlWm.surface);
zwp_confined_pointer_v1_destroy(confine);
wl_surface_commit(wlWm.surface);
wl_region_destroy(region);
uint64_t warpSeq = app_mouseSeq();
LG_UNLOCK(wlWm.surfaceLock);
MLOG(warpSeq, "warp req=%d,%d target=%d,%d exit=%d temp=%u",
reqX, reqY, x, y, exiting, tempId);
} }
void waylandRealignPointer(void) void waylandRealignPointer(void)

View File

@@ -34,6 +34,13 @@
static struct Option waylandOptions[] = static struct Option waylandOptions[] =
{ {
{
.module = "wayland",
.name = "warpSupport",
.description = "Enable cursor warping",
.type = OPTION_TYPE_BOOL,
.value.x_bool = true,
},
{ {
.module = "wayland", .module = "wayland",
.name = "fractionScale", .name = "fractionScale",
@@ -133,6 +140,7 @@ static bool waylandInit(const LG_DSInitParams params)
wl_list_init(&wlWm.surfaceOutputs); wl_list_init(&wlWm.surfaceOutputs);
wlWm.warpSupport = option_get_bool("wayland", "warpSupport");
wlWm.useFractionalScale = option_get_bool("wayland", "fractionScale"); wlWm.useFractionalScale = option_get_bool("wayland", "fractionScale");
if (!waylandPollInit()) if (!waylandPollInit())
@@ -215,7 +223,7 @@ static bool waylandGetProp(LG_DSProperty prop, void * ret)
{ {
if (prop == LG_DS_WARP_SUPPORT) if (prop == LG_DS_WARP_SUPPORT)
{ {
*(enum LG_DSWarpSupport*)ret = LG_DS_WARP_NONE; *(enum LG_DSWarpSupport*)ret = wlWm.warpSupport ? LG_DS_WARP_SURFACE : LG_DS_WARP_NONE;
return true; return true;
} }

View File

@@ -142,6 +142,7 @@ struct WaylandDSState
bool fractionalScale; bool fractionalScale;
bool needsResize; bool needsResize;
bool configured; bool configured;
bool warpSupport;
struct WlMotion motion; struct WlMotion motion;
double scrollState; double scrollState;