[Xcb] I’m writing a launcher and I need to capture the keyboard

Julien Danjou julien at danjou.info
Wed Mar 21 08:21:24 PDT 2012


On Wed, Mar 21 2012, Alexander Teinum wrote:

> So far I have managed to write a launcher that simply captures the
> keyboard in a window[1] by subscribing to the KeyPress-event for that
> window and setting window class to InputOutput. I’ve experimented with
> setting the window class to InputOnly, but it didn’t capture keyboard
> events. I have also played around with override-redirect, but I
> couldn’t get things to work with that either.  I also tried using
> GrabKeyboard on the root window, and it worked when the launcher was
> launched from a terminal (uxterm), but I use my window manager (dwm)
> to launch my launcher.

The Go version of XGrabKeyboard(3) is what you need.

Be careful that if you launch your application with something like
dmenu, which grab the keyboard, you may fail to grab it too at your
application startup. This is the first thing I can think about when you
describe your problem, since it should work whatever the way you use to
start your application.

-- 
           Julien
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20120321/47fb371e/attachment.pgp>


More information about the Xcb mailing list