Skip to content

Fix Android pointer grabs after right-click and focus loss - #299

Draft
4Luke4 wants to merge 1 commit into
localdesktop:mainfrom
4Luke4:agent/fix-android-pointer-input
Draft

Fix Android pointer grabs after right-click and focus loss#299
4Luke4 wants to merge 1 commit into
localdesktop:mainfrom
4Luke4:agent/fix-android-pointer-input

Conversation

@4Luke4

@4Luke4 4Luke4 commented Jul 23, 2026

Copy link
Copy Markdown

Summary

Fix Android pointer input state getting stuck after right-clicks, interrupted gestures, and app focus transitions.

Root cause

Android's button_state() describes the button mask after the current motion event. On affected devices, a secondary-button release therefore arrives with an empty mask. The patched winit Android backend maps that empty mask to the left button, causing LocalDesktop to send a left-button release after a right-button press. The Wayland compositor never receives the matching right-button release and retains the pointer grab, making subsequent clicks appear frozen.

Android may also interrupt an active gesture when the app loses focus without delivering the corresponding release or cancellation event.

Changes

  • Track physical Linux pointer button codes currently held by Android.
  • Reconcile malformed release events with the sole button known to be pressed.
  • Release all tracked physical pointer buttons when the Android window loses focus.
  • Cancel synthesized touch drags and reset touch gesture bookkeeping on focus loss.
  • Use a real Smithay serial when assigning keyboard focus from pointer input.
  • Consolidate pointer-button emission so press, release, and recovery paths use identical framing behavior.

User impact

This should prevent the desktop from becoming unresponsive after:

  • opening and closing a right-click context menu;
  • using an external mouse on affected Android devices;
  • switching away from LocalDesktop and returning;
  • losing focus during a mouse or touch drag.

Related issues

Addresses the shared input-state failure reported in:

Issue #278 concerns cursor ownership and sizing rather than button-state recovery. It should be implemented separately because it requires Android platform cursor visibility support plus compositor-side cursor rendering; coupling that work to grab recovery would make regressions substantially harder to isolate.

Validation

  • Confirmed the branch is based directly on main and contains one modified file.
  • Reviewed all pointer press/release paths for balanced Wayland events and frames.
  • Added poison-tolerant synchronization for recovery state.
  • Android compilation and device-level validation are delegated to repository CI and maintainer testing because an Android SDK/NDK toolchain is unavailable in this execution environment.

Suggested device checks

  1. Right-click repeatedly in the desktop and taskbar.
  2. Open and dismiss context menus, then left-click elsewhere.
  3. Switch to another Android/DeX app while a button is held, then return.
  4. Repeat with a physical mouse and a DeX touchpad.
  5. Verify single-finger drag and two-finger scrolling remain functional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant