On Wed, May 10, 2017 at 08:16:07PM +0200, Sebastian Reuße wrote: > 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
pushed, thanks. I made a minor modification for readability before pushing. I'm not a fan of if (!foo && !(foo = bar())) because it's too easy to read over it. Slightly better is an explicit NULL comparison: if (!foo && (foo = bar()) == NULL) but my favourite here is a simple: if (!foo) foo = bar(); if (!foo) boom then we just hope the compiler gods shine their light and optimise this ;) Cheers, Peter ------------------------------------------------------------------------------ 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