[Xcb] Best way to obtain text input in XCB

Michael Stapelberg michael+xcb at stapelberg.de
Fri Oct 26 12:12:31 PDT 2012


Hi Nicholas,

Nicholas Allen <nick.allen at onlinehome.de> writes:
> We have an application that was ported from Xlib to XCB (as recommended 
> by someone on this list) but unfortunately the text input is now broken 
> because there doesn't seem to be any equivalent for doing this with XCB. 
> What is the best way to do this? Should we use a mixed XCB/Xlib API? If 
> so what API is currently the standard for getting text input on Linux? 
> We can't use high level APIs like Gtk or Qt so am looking for some 
> documentation on the best way to do this (ideally with just XCB but 
> mixed Xlib/XCB approach would also be possible for us).
I suppose with text input you mean translating KeyPress events to UTF-8.

I recently ported i3lock (which uses XCB) to libxkbcommon (I was doing
most of the state handling on my own before and that’s really crazy,
wrong and buggy). Find the commit at
http://code.stapelberg.de/git/i3lock/commit/?id=e1d86a32
and/or browse the code at
http://code.stapelberg.de/git/i3lock/tree/?id=e1d86a32

This solution depends on Xlib (for XKB stuff) and libxkbcommon >= 0.2.0
(which is very recent). AFAIK, this is the best way to get text input
when using XCB currently.

Ran Benita, one of the authors of libxkbcommon, suggested that if you
don’t mind more Xlib dependencies, you could use a more mixed solution:
> So you would just use Xlib for XkbGetKeyboard and XkbTranslateKeycode
> (and possibly XkbTranslateKeysym instead of keysym2ucs.c). Be sure
> though, to move XkbGetKeyboard out of the loop (that's really bad),
> and refresh it when needed.

I hope that helps somewhat (and yes, the state of input handling with
XCB is pretty bad :-/).

-- 
Best regards,
Michael


More information about the Xcb mailing list