Skip to content

x11: Modernize and optimize key handling #13488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2025

Conversation

Kontrabant
Copy link
Contributor

Modernize and optimize X11 key handling. This reworks keymaps to be handled similarly to how they are under Wayland for faster construction and group switching, and generally modernizes key handling when the Xkb extension is available (which it should always be, as it is about 30 years old).

  • Use modern Xkb functions where appropriate and cleanly separate the modern and legacy paths.
  • Remove the deprecated XKeycodeToKeysym function in favor of directly querying the keysym map on the legacy path.
  • Look up virtual modifiers by name on the Xkb path to better handle remapping (equivalent to the modifier handling under Wayland).
  • Optimize keymap creation on the Xkb path to cut keymap build times and enable fast group switching (equivalent to keymap handling on Wayland).
  • Enable and handle Xkb events to handle changes to the group, mapping, and modifier states. This is more reliable than using the legacy events (group changes may not arrive if the window lacks pointer focus), and better handles cases where modifiers are latched, locked, or activated externally rather than physically pressed (again, similar to the Wayland handling).

@Kontrabant Kontrabant added this to the 3.4.0 milestone Jul 31, 2025
@Kontrabant Kontrabant changed the title x11: Refactor keymap handling x11: Modernize and optimize key handling Jul 31, 2025
@Kontrabant Kontrabant force-pushed the x_keymap_opt branch 2 times, most recently from 1936b81 to 6b5ac9f Compare August 3, 2025 21:59
@slouken slouken requested a review from icculus August 4, 2025 16:48
- Use modern Xkb functions where appropriate and cleanly separate the modern and legacy paths.
- Remove the deprecated XKeycodeToKeysym function in favor of directly querying the keymap on the legacy path.
- Look up virtual modifiers by name on the Xkb path to better handle remapping (equivalent to the modifier handling under Wayland).
- Optimize keymap creation on the Xkb path to cut keymap build times and enable fast group switching  (equivalent to keymap handling on Wayland).
- Enable and handle Xkb events to handle changes to the group, mapping, and modifier states. This is more reliable than using the legacy events (group changes may not arrive if the window lacks pointer focus), and better handles cases where modifiers are latched, locked, or activated externally rather than physically pressed.
@Kontrabant
Copy link
Contributor Author

Just to note, I've been over this a couple more times, and there's nothing left to do, so ready for review.

@slouken slouken removed the request for review from icculus August 6, 2025 18:44
@slouken slouken merged commit f439e44 into libsdl-org:main Aug 6, 2025
41 checks passed
@slouken
Copy link
Collaborator

slouken commented Aug 6, 2025

Merged, thanks!

@Kontrabant Kontrabant deleted the x_keymap_opt branch August 6, 2025 21:46
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.

2 participants