Skip to content

Commit f439e44

Browse files
Kontrabantslouken
authored andcommitted
x11: Modernize and optimize key handling
- 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.
1 parent 67e5130 commit f439e44

File tree

8 files changed

+550
-304
lines changed

8 files changed

+550
-304
lines changed

cmake/sdlchecks.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ macro(CheckX11)
390390
set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1)
391391
endif()
392392

393-
check_symbol_exists(XkbLookupKeySym "X11/Xlib.h;X11/XKBlib.h" SDL_VIDEO_DRIVER_X11_HAS_XKBLOOKUPKEYSYM)
393+
check_include_file("X11/XKBlib.h" SDL_VIDEO_DRIVER_X11_HAS_XKBLIB)
394394

395395
if(SDL_X11_XCURSOR AND HAVE_XCURSOR_H AND XCURSOR_LIB)
396396
set(HAVE_X11_XCURSOR TRUE)

include/build_config/SDL_build_config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@
422422
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR@
423423
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS @SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS@
424424
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XTEST @SDL_VIDEO_DRIVER_X11_DYNAMIC_XTEST@
425-
#cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBLOOKUPKEYSYM 1
425+
#cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBLIB 1
426426
#cmakedefine SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1
427427
#cmakedefine SDL_VIDEO_DRIVER_X11_XCURSOR 1
428428
#cmakedefine SDL_VIDEO_DRIVER_X11_XDBE 1

src/video/x11/SDL_x11dyn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <X11/Xatom.h>
2929
#include <X11/Xresource.h>
3030

31-
#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBLOOKUPKEYSYM
31+
#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBLIB
3232
#include <X11/XKBlib.h>
3333
#endif
3434

src/video/x11/SDL_x11events.c

Lines changed: 273 additions & 116 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)