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

Daniel Martin consume.noise at gmail.com
Thu Oct 11 00:52:38 PDT 2012


On 10 October 2012 11:54, Michael Stapelberg <michael+xcb at stapelberg.de> wrote:
> because X11 input handling is rather complicated, I thought I’d port the
> code I’m using in i3lock to xcb-util so that others can profit from it
> (and I don’t have to duplicate it in every tool). Essentially, it is a
> simpler version (for the caller) of xcb_key_press_lookup_keysym which
> keeps track of Mode_switch, ISO_Level3_Shift, ISO_Level5_Shift,
> Num_Lock, Shift_Lock and Caps_Lock.

Why don't you use the XInput2 extension, i.e. with XIGrabKeycode()? On a key
press/release event you'll receive a XIDeviceEvent, which contains
everything you need:
- key code in the 'detail' field and
- active modifiers in 'mods'.
Just have a look at /usr/include/X11/extensions/XInput2.h.

Peter Hutterer has got some blog posts with "XI2 recipes":
- they are linked here http://www.x.org/wiki/XI2 (if available)
- or:
  http://who-t.blogspot.com/2009/07/xlib-cookie-events.html
  http://who-t.blogspot.com/2009/05/xi2-recipes-part-1.html
  http://who-t.blogspot.com/2009/06/xi2-recipies-part-2.html
  http://who-t.blogspot.com/2009/06/xi2-recipes-part-3.html
  http://who-t.blogspot.com/2009/07/xi2-recipes-part-4.html
  http://who-t.blogspot.com/2009/07/xi2-recipes-part-5.html
  http://who-t.blogspot.com/2009/07/xi2-recipes-part-6.html

cheers,
   Daniel Martin


More information about the Xcb mailing list