getting all kbd events
peter.hutterer at who-t.net
Thu Jul 9 02:47:35 PDT 2009
On Thu, Jul 09, 2009 at 09:18:18AM +0000, Nokan Emiro wrote:
> On Thu, Jul 9, 2009 at 12:01 AM, Peter Hutterer <peter.hutterer at who-t.net>wrote:
> > On Wed, Jul 08, 2009 at 10:24:20PM +0200, Nokan Emiro wrote:
> > > Is Xi2 able to deliver me key events when an XGrabKeyboard() by a
> > > different client is in effect?
> > no. that's kinda the point of grab (amongst other things).
> Wrong news...
> If so, then what is the way of writing an X client, that can get all the key
Each event gets delivered for one window only - but to all the clients
registering on this window. To get all key events you need to register for
key events on all visible windows.
Note this only works when there is no grab, events during active grabs are
delivered to the grabbing client only.
> For example: how would you write a universal macro recorder?
> How would you write a keylogger in X level?
xrecord (if it wasn't broken) might help there I think.
> How would you write a task manager, that always gets the focus when the
> user presses Ctrl-Alt-T ?
man XGrabKey/XGrabButton. These are so-called "passive grabs" and are
delivered to the highest window above the event window that registered an
passive grab. Passive grabs however may only activate if there is no active
grab on the device. Menus use passive grabs (combined with active ones,
usually). You'll notice that while a menu is active you can't alt-tab or
invoke other shortcuts.
> All these apps have to get all the key events even if someone else
> grabbed the keyboard. For example if VNC (or any other remote desktop)
> clients, virtual machine console apps, or such programs grab the keyboard,
> I think it should be possible to record the users activity...
grabs have a particular use-case for which they are (within reason) useful.
They aren't perfect and the keylogger is one example for that.
there are ideas floating around to make them more useful but AFAICT none of
them will be available in the near future (lack of time).
More information about the xorg