diff options
author | Alexander Golubev <fatzer2@gmail.com> | 2024-02-29 13:48:57 +0300 |
---|---|---|
committer | Alexander Golubev <fatzer2@gmail.com> | 2024-03-04 13:51:02 +0300 |
commit | beb37238fa751dada93695a8b9ce1bb73aea1253 (patch) | |
tree | 96d0122ac8b243c19b56131d84f327a141b18da8 /src/kernel/qapplication_x11.cpp | |
parent | 2f15a471f912b8ef5bc11d215f8937a37da42b87 (diff) | |
download | tqt3-beb37238fa751dada93695a8b9ce1bb73aea1253.tar.gz tqt3-beb37238fa751dada93695a8b9ce1bb73aea1253.zip |
Fix FTBFS with -no-xkb
The analogue of XkbKeycodeToKeysym() used to be XKeycodeToKeysym(), but
it was deprecated in favour of XGetKeyboardMapping() method.
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
Diffstat (limited to 'src/kernel/qapplication_x11.cpp')
-rw-r--r-- | src/kernel/qapplication_x11.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index 2cda2b8b3..f5f2701ad 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -1621,6 +1621,21 @@ static Visual *find_truecolor_visual( Display *dpy, int scr, int *depth, int *nc return v; } +static KeySym qt_x11_keycode_to_keysym(Display *dpy, KeyCode kc) { +#ifndef TQT_NO_XKB + return XkbKeycodeToKeysym(dpy, kc, 0, 0); +#else + KeySym rv = NoSymbol; + int keysyms_per_keycode; + KeySym *keysym_p = XGetKeyboardMapping(dpy, kc, 1, &keysyms_per_keycode); + if (keysyms_per_keycode>0) { //< Should always be true unless X server is bugged + rv = keysym_p[0]; + } + XFree(keysym_p); + + return rv; +#endif // TQT_NO_XKB +} /***************************************************************************** tqt_init() - initializes TQt for X11 @@ -2151,8 +2166,7 @@ void tqt_init_internal( int *argcptr, char **argv, for (maskIndex = 0; maskIndex < 8; maskIndex++) { for (i = 0; i < map->max_keypermod; i++) { if (map->modifiermap[mapIndex]) { - KeySym sym = - XkbKeycodeToKeysym(appDpy, map->modifiermap[mapIndex], 0, 0); + KeySym sym = qt_x11_keycode_to_keysym(appDpy, map->modifiermap[ mapIndex ]); if ( qt_alt_mask == 0 && ( sym == XK_Alt_L || sym == XK_Alt_R ) ) { qt_alt_mask = 1 << maskIndex; @@ -2181,8 +2195,7 @@ void tqt_init_internal( int *argcptr, char **argv, for ( i = 0; i < map->max_keypermod; i++ ) { if ( map->modifiermap[ mapIndex ] ) { - KeySym sym = - XkbKeycodeToKeysym( appDpy, map->modifiermap[ mapIndex ], 0, 0 ); + KeySym sym = qt_x11_keycode_to_keysym(appDpy, map->modifiermap[ mapIndex ]); if ( sym == XK_Mode_switch ) { qt_mode_switch_remove_mask |= 1 << maskIndex; } |