Greedy XGrabKeyboard

Peter Hutterer peter.hutterer at who-t.net
Wed May 19 16:02:22 PDT 2010


On Wed, May 19, 2010 at 01:41:46PM +0100, belnac wrote:
> On Wed, 2010-05-19 at 21:29 +1000, Peter Hutterer wrote:
> > Google for the RECORD extension, the syndaemon program (part of the
> > synaptics driver) has some example code to do this.
> 
> Thanks for your reply Peter.
> 
> I was more looking for an event driven solution rather than one that
> involves polling the keyboard state for depressed keys every x
> milliseconds as the syndaemon seems to do.

syndaemon has two backends, one is the polling one, one is the RECORD
extension based one (--enable-record configure flag I think). the record
extension is event based, any event generated by the server is forwarded to
the client on a data connection, so no polling is involved.

> One solution I found consists of listening to KeyPress events on every
> single window by issuing XSelectInput (and passing KeyPressMask) on
> every single window instance (in a parent->children recursive way.) I
> got it to work and am now struggling to create yet another sniffer that
> listens to window creation events so keyboard input can be listened to
> as new windows are created dynamically.
> 
> Perhaps my design is just wrong?

no, this is the only way to go about it though note that you may not get
events if there is an active grab on a device. so this may not really be the
solution you want.

Cheers,
  Peter



More information about the xorg mailing list