[client] input: stop absolute cursor feedback
Some checks are pending
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Waiting to run
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Waiting to run
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Waiting to run
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Waiting to run
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Waiting to run
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Waiting to run
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Waiting to run
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Waiting to run
build / module (push) Waiting to run
build / host-linux (push) Waiting to run
build / host-windows-cross (push) Waiting to run
build / host-windows-native (push) Waiting to run
build / idd (push) Waiting to run
build / obs (clang) (push) Waiting to run
build / obs (gcc) (push) Waiting to run
build / docs (push) Waiting to run

X11's legacy guest-position synchronization warps the host cursor to
delayed guest updates. With absolute input this feeds old positions back
through cooked motion and pulls the cursor away from window edges.

Skip display-server guest synchronization when the active input is
absolute. Relative input and explicit uncapture alignment are unchanged.
This commit is contained in:
Geoffrey McRae
2026-08-10 19:29:22 +10:00
parent 89dcf56073
commit d20904e3af
3 changed files with 46 additions and 10 deletions

View File

@@ -642,6 +642,11 @@ void core_stopFrameThread(void)
void core_handleGuestMouseUpdate(void) void core_handleGuestMouseUpdate(void)
{ {
/* The local cursor is authoritative with absolute input. Sending delayed
* guest positions back to the display server creates a warp feedback loop. */
if (lgInput_supports(LG_INPUT_SUPPORT_MOUSE_ABSOLUTE))
return;
struct DoublePoint localPos; struct DoublePoint localPos;
if (!util_guestCurToLocal(&localPos)) if (!util_guestCurToLocal(&localPos))
{ {

View File

@@ -120,6 +120,7 @@ set(MOUSE_CASES
surface-exit surface-exit
exit-immediate exit-immediate
exit-guest exit-guest
absolute-sync
exit-reentry exit-reentry
view-immediate view-immediate
capture-pending capture-pending

View File

@@ -262,9 +262,8 @@ void app_mouseTrace(const char * file, unsigned int line,
static bool inputSupports(void * opaque, LG_InputSupport support) static bool inputSupports(void * opaque, LG_InputSupport support)
{ {
(void)opaque; return support == LG_INPUT_SUPPORT_MOUSE_ABSOLUTE &&
(void)support; opaque && *(const bool *)opaque;
return false;
} }
static bool inputKey(void * opaque, int key) static bool inputKey(void * opaque, int key)
@@ -281,6 +280,17 @@ static bool inputMouseMotion(void * opaque, int32_t x, int32_t y)
return true; return true;
} }
static bool inputMousePosition(void * opaque, uint32_t x, uint32_t y,
uint32_t width, uint32_t height)
{
(void)opaque;
(void)x;
(void)y;
(void)width;
(void)height;
return true;
}
static bool inputMouseButton(void * opaque, unsigned int button) static bool inputMouseButton(void * opaque, unsigned int button)
{ {
(void)opaque; (void)opaque;
@@ -294,6 +304,7 @@ static const LG_InputOps inputOps = {
.keyDown = inputKey, .keyDown = inputKey,
.keyUp = inputKey, .keyUp = inputKey,
.mouseMotion = inputMouseMotion, .mouseMotion = inputMouseMotion,
.mousePosition = inputMousePosition,
.mousePress = inputMouseButton, .mousePress = inputMouseButton,
.mouseRelease = inputMouseButton, .mouseRelease = inputMouseButton,
}; };
@@ -482,6 +493,24 @@ static void testExitGuest(void)
CHECK(count(EV_GUEST) == 0); CHECK(count(EV_GUEST) == 0);
} }
static void testAbsoluteSync(void)
{
reset();
setLocal(50, 50);
core_handleGuestMouseUpdate();
CHECK(count(EV_GUEST) == 1);
bool absolute = true;
lgInput_setFallback(&inputOps, &absolute);
m.count = 0;
core_handleGuestMouseUpdate();
CHECK(count(EV_GUEST) == 0);
lgInput_setFallback(&inputOps, NULL);
}
static void testExitReentry(void) static void testExitReentry(void)
{ {
startExit(); startExit();
@@ -895,6 +924,7 @@ static const struct Test tests[] = {
{ "surface-exit" , testSurfaceExit }, { "surface-exit" , testSurfaceExit },
{ "exit-immediate" , testExitImmediate}, { "exit-immediate" , testExitImmediate},
{ "exit-guest" , testExitGuest }, { "exit-guest" , testExitGuest },
{ "absolute-sync" , testAbsoluteSync },
{ "exit-reentry" , testExitReentry }, { "exit-reentry" , testExitReentry },
{ "view-immediate" , testViewImmediate}, { "view-immediate" , testViewImmediate},
{ "capture-pending" , testCapWait }, { "capture-pending" , testCapWait },