[Xcb] [RFC] xcb/util-keysyms input handling patch

Daniel Martin consume.noise at gmail.com
Mon Oct 15 12:38:20 PDT 2012


On Fri, Oct 12, 2012 at 10:03:36PM +0200, Michael Stapelberg wrote:
> Michael Stapelberg <michael+xcb at stapelberg.de> writes:
...
> 1. Is using the function XkbTranslateKeyCode appropriate for this? It
>    feels slightly kludgy to use XkbBuildCoreState, but I could not
>    figure out what the correct shift level is for calling
>    XkbKeycodeToKeysym (it does NOT map 1:1 to the KeyPress’s
>    mods.effective in all cases).
> 
> 2. Is getting the core keyboard via XKB correct?

For my part, I've never used the XKB stuff. You can pump the keycode
into XKeycodeToKeysym(), into XKeysymToString(). And mods.effective
could be tested against {Shift,Lock,Control,Mod1,...}Mask from X.h.

...

>     while (1) {
>         printf("next event\n");
>         XGenericEventCookie *cookie = (XGenericEventCookie*)&ev->xcookie;
>         XNextEvent(display, (XEvent*)ev);
> 
>         if (XGetEventData(display, cookie) &&
>             cookie->type == GenericEvent &&
>             cookie->extension == xi_opcode)
>         {

...
Don't forget to use XFreeEventData(). I assume you've left it out in
this example.

>         }
>     }
> }


More information about the Xcb mailing list