mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-06 22:04:12 +01:00
WINGs: Add W_KeycodeToKeysym to replace XKeycodeToKeysym/XkbKeycodeToKeysym calls
XKeycodeToKeysym was deprecated some time ago and we replaced those function calls to XkbKeycodeToKeysym. Usage of XkbKeycodeToKeysym is not the best as it appears the XKEYBOARD can be disabled via xorg.conf (at least on Linux). So just replacing XKeycodeToKeysym() with XkbKeycodeToKeysym() could cause run-time errors on top of the compilation warning we may have. Better fix is to address the problem without introducing a dependency on XKEYBOARD. W_KeycodeToKeysym is the equivalent code for XKeycodeToKeysym/XkbKeycodeToKeysym using XGetKeyboardMapping instead. As a new function is added to the library WINGs library version is bumped.
This commit is contained in:
committed by
Carlos R. Mafra
parent
2dd98666f1
commit
15d06ff064
@@ -213,3 +213,35 @@ int W_LookupString(W_View *view, XKeyPressedEvent *event, char *buffer, int bufl
|
||||
#endif
|
||||
return XLookupString(event, buffer, buflen, keysym, (XComposeStatus *) status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Map a keycode to the corresponding keysym
|
||||
* To replace the deprecated X11 function XKeycodeToKeysym
|
||||
*/
|
||||
KeySym W_KeycodeToKeysym(Display *display, KeyCode keycode, int index)
|
||||
{
|
||||
static int min_kc = -1;
|
||||
static int max_kc;
|
||||
int num_syms;
|
||||
KeySym *key_syms;
|
||||
KeySym ks;
|
||||
|
||||
if (min_kc == -1) {
|
||||
(void) XDisplayKeycodes(display, &min_kc, &max_kc);
|
||||
}
|
||||
|
||||
if (keycode < min_kc || keycode > max_kc || index < 0) {
|
||||
return NoSymbol;
|
||||
}
|
||||
|
||||
key_syms = XGetKeyboardMapping(display, keycode, 1, &num_syms);
|
||||
if (index >= num_syms) {
|
||||
XFree(key_syms);
|
||||
return NoSymbol;
|
||||
}
|
||||
|
||||
ks = key_syms[index];
|
||||
XFree(key_syms);
|
||||
|
||||
return ks;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user