[client] wayland: constrain pointer only during capture
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled

Remove the persistent confined-pointer workaround that emulated cursor
warping on Wayland. Normal pointer motion now uses absolute input only.

Create relative and locked pointer objects only during capture. Preserve
the request across pointer capability changes, and suppress relative
events until the compositor confirms the lock.

On uncapture, publish the current absolute position instead of trying to
warp the host cursor.
This commit is contained in:
Geoffrey McRae
2026-08-09 03:32:38 +10:00
parent 48f0b66a4f
commit 9f2d6f6413
9 changed files with 124 additions and 531 deletions

View File

@@ -327,10 +327,13 @@ void core_setGrabQuiet(bool enable)
/* ensure the local mouse is inside the window before we capture, this fixes
* odd UI behaviour if the user is using focus follows mouse and the window
* was focused without the cursor being in window already */
struct DoublePoint local;
const bool valid = util_guestCurToLocal(&local);
MTRACE("grab align valid=%d", valid);
core_warpPointer(local.x, local.y, true);
if (warpSupport != LG_DS_WARP_NONE)
{
struct DoublePoint local;
const bool valid = util_guestCurToLocal(&local);
MTRACE("grab align valid=%d", valid);
core_warpPointer(local.x, local.y, true);
}
if (g_params.grabKeyboard)
g_state.ds->grabKeyboard();
@@ -348,13 +351,18 @@ void core_setGrabQuiet(bool enable)
g_state.ds->uncapturePointer();
if (!g_params.captureInputOnly && warpSupport != LG_DS_WARP_NONE)
applyView(g_state.ds->isPointerGrabbed(), false);
if (warpSupport == LG_DS_WARP_NONE)
core_handleMouseAbsolute();
else
{
if (!g_params.captureInputOnly)
applyView(g_state.ds->isPointerGrabbed(), false);
/* if exiting capture when input on capture only we need to align the local
* cursor to the guest's location before it is shown. */
if (g_params.captureInputOnly || !g_params.hideMouse)
core_alignToGuest();
/* if exiting capture when input on capture only we need to align the
* local cursor to the guest's location before it is shown. */
if (g_params.captureInputOnly || !g_params.hideMouse)
core_alignToGuest();
}
}
}
@@ -372,6 +380,14 @@ bool core_warpPointer(int x, int y, bool exiting)
return false;
}
enum LG_DSWarpSupport warpSupport = LG_DS_WARP_NONE;
app_getProp(LG_DS_WARP_SUPPORT, &warpSupport);
if (warpSupport == LG_DS_WARP_NONE)
{
MTRACE("warp drop=support target=%d,%d exit=%d", x, y, exiting);
return false;
}
if (!exiting && g_cursor.warpState == WARP_STATE_OFF)
{
MTRACE("warp drop=state target=%d,%d exit=%d", x, y, exiting);