Skip to content

x11: gate keyboard input and mouse grab on active window PID#2434

Open
awsms wants to merge 1 commit intoares-emulator:masterfrom
awsms:fix/x11-focus-input-gating
Open

x11: gate keyboard input and mouse grab on active window PID#2434
awsms wants to merge 1 commit intoares-emulator:masterfrom
awsms:fix/x11-focus-input-gating

Conversation

@awsms
Copy link
Contributor

@awsms awsms commented Feb 27, 2026

Prevent keyboard state updates and mouse pointer grab from remaining active when the focused X11 window does not belong to this process.

  • Keyboard: ignore XQueryKeymap results unless the active _NET_ACTIVE_WINDOW resolves to our PID.
  • Mouse: automatically release pointer grab when focus leaves our window/process to avoid stuck cursor after alt-tab.
  • GLX: explicitly set _NET_WM_PID on the GLX child window so focus attribution works reliably.

This ensures input is only processed while ares owns focus and avoids global key state leakage or cursor capture issues under X11 and Xwayland. The fix does not impact the Drivers->Input setting "When focus is lost" behavior; controller will still be able to trigger keys if set as "Allow input".

This commit replaces the whole workaround I previously attempted with #2431, to let the X server handling the windows as usual, instead of messing around with the desktop-ui/ logic.

edit: on hold, will try to get the windows fix merged as well. we're still waiting for testing feedback on macOS

Prevent keyboard state updates and mouse pointer grab from
remaining active when the focused X11 window does not belong
to this process.

- Keyboard: ignore XQueryKeymap results unless the active
  _NET_ACTIVE_WINDOW resolves to our PID.
- Mouse: automatically release pointer grab when focus leaves
  our window/process to avoid stuck cursor after alt-tab.
- GLX: explicitly set _NET_WM_PID on the GLX child window so
  focus attribution works reliably.

This ensures input is only processed while ares owns focus
and avoids global key state leakage or cursor capture issues
under X11.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant