Gamescope: a touch in a black bar no longer offsets later taps

Merged
UT
12d ago
+17-11

Description

In Gamescope mode with touchscreen mode on, a tap in a black bar beside the picture made every later tap land a fixed distance to the left or right.

Cause: the app sends an absolute pointer position to the compositor as a relative move from the cursor position it tracks itself. A tap in a bar maps to a position past the screen edge. The compositor stops its cursor at the edge, but the app kept the position past the edge, so the two no longer agreed and nothing brought them back together.

Fix: the tracked position now stops at the screen edges, as the compositor's cursor does.

  • GamescopeInputSink clamps an absolute target to the screen before it computes the move, and clamps its tracked position after a relative move. The relative move itself is sent unchanged.
  • XServer clamps its own pointer position the same way on the Gamescope path.

The same drift happened when a mouse or a controller stick mapped to the mouse was held against a screen edge and a tap followed; this fixes that case too. X11 mode is not changed.

Device run, Poco F6, Balatro, 1280x720 container on a 2712x1220 panel (bars left and right), touchscreen mode on, stock payload: after a tap in the left bar, in the right bar, and after a swipe that ended in a bar, the next tap landed on the tap point and opened the right menu button; a tap just outside a button edge did not activate it; no crash in logcat. Taps were injected with adb (150 ms press). The mouse or stick followed by a tap case was not run.

Recording

Type of Change

  • Bug fix
  • Performance / stability improvement
  • Compatibility improvements
  • Other (requires prior approval)

Checklist

  • If I have access to #code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed.
  • This change aligns with the current project scope (core functionality, stability, or performance). If not, it has been explicitly approved beforehand.
  • I have attached a recording of the change.
  • I have read and agree to the contribution guidelines in CONTRIBUTING.md.

Summary by cubic

Fixes a Gamescope touchscreen bug where tapping a letterbox black bar made every later tap land a fixed distance off, because the app tracked the cursor past the screen edge while the compositor's cursor stopped at the edge.

Bug Fixes

  • GamescopeInputSink and XServer now clamp the tracked pointer position to the screen bounds before computing relative motion.
  • Also fixes the same drift when a mouse or controller stick is held against a screen edge before a tap.

Summary by CodeRabbit

  • Bug Fixes
    • Pointer movement is now constrained to the screen’s boundaries for both direct positioning and directional movement. The cursor no longer travels beyond the visible display edges, helping keep pointer interactions aligned with the on-screen area.