XkbGetMap is more robust in cases where certain keyboard description components
are missing. XkbGetKeyboard will fail when any component cannot be resolved;
since XkbAllComponentsMask is requested, any missing component will result in
the call returning NULL. Since we don’t necessarily need all components (e.g.,
keyboard geometry, keymap names), we use XkbGetMap instead.

Signed-off-by: Sebastian Reuße <s...@wirrsal.net>
---
 tools/xsetwacom.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index bbc92f1..b0f21e4 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -1173,9 +1173,10 @@ static int keysym_to_keycode(Display *dpy, KeySym sym)
        XkbStateRec state;
        int kc = 0;
 
-
-       if (!xkb)
-               xkb = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
+       if (!xkb && !(xkb = XkbGetMap(dpy, XkbAllComponentsMask, 
XkbUseCoreKbd))) {
+               fprintf(stderr, "Warning: failed to query keyboard map\n");
+               goto out;
+       }
        XkbGetState(dpy, XkbUseCoreKbd, &state);
 
        for (kc = xkb->min_key_code; kc <= xkb->max_key_code; kc++)
-- 
2.12.2


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to