Fix Gamescope cursor sync after guest warps

Closed
BU
4d ago
+24-2

Root cause

GamescopeInputSink keeps a private absolute cursor position for converting Android absolute moves into relative seat motion. Guest-side XWarpPointer updates XServer.pointer through Pointer.setPosition, but the sink cache was never updated, so the next Android move used stale coordinates and visibly desynchronized the cursor.

Fix

  • Add attach/detach lifecycle callbacks to XServer.InputEventSink.
  • Have GamescopeInputSink observe XServer pointer motion while attached.
  • Initialize the cache from the current X pointer and remove the listener when the sink is replaced.

Evidence

The support trace shows the game remained alive and continuously polled input through XInputGetState while the cursor diverged only under the Gamescope/new-renderer path. The relevant stale cache was in app/src/main/java/app/gamenative/display/GamescopeInputSink.kt, while guest pointer warps notify listeners through app/src/main/java/com/winlator/xserver/Pointer.java.

No build was run in the support workspace.

Summary by CodeRabbit

  • Bug Fixes
    • Absolute pointer input now uses the latest cursor position, helping keep pointer actions aligned with the on-screen cursor as it moves.
    • Pointer tracking now updates when the input handler is attached and stops when it is detached, reducing the chance of stale cursor coordinates affecting input.