Listen to input from core pointer/keyboard devices
Andrey Pokrovskiy
wonder.mice at gmail.com
Mon Feb 9 02:50:16 PST 2009
Hello,
To be clear, all I need is to listen to pointer (mouse) motion/buttons
events globally. I want to be notified about every pointer move on every
screen (without respect to on what window pointer was when moving and to
what window has grabed it).
I found 3 ways to do it:
1. Poll it (like in xeyes). It is not the way I really need it. If polling
interval will be long, I will not receive enough motion event to be smooth.
Short polling interval just wastes CPU cycles.
2. Receive MotionNotify from every window (the synergy way). The idea is to
select MotionNotify event for every window on every screen. We will also
need to select CreateNotify event to select MotionNotify for newly created
windows. The bad side of this, that if some windows grabs the pointer we
will not receive any events, because they are delivered only to window that
grabs the pointer.
3. Listen to device events (I failed to find some popular examples). We can
use XListInputDevices() to get list of available devices. The we can open
one of it (for example, that has type "MOUSE") using XOpenDevice() and then
call XSelectExtensionEvent() to select inpu from it. It works great when we
have at least on extension device in the list (also, behavior can vary
between different extension devices, but it is not the problem now).
Lets talk about 3. We can have only 2 devices in list: "core keyboard" and
"core pointer" (which are of IsXKeyboard and IsXpointer use flags in
corresponding XDeviceInfo structure). As written in man, XOpenDevice() will
fail for X keyboard and X pointer. I don't understand why it is designed so
and what the problem was solved by this, but it is the problem for me now :)
So, the question can be devided on two parts:
1. Is there ant way to select X pointer/keyboard (core devices) events?
2. Maybe there is more direct/simple/right way to do what I need?
Thanks :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.x.org/archives/xorg-devel/attachments/20090209/66af26ef/attachment.html
More information about the xorg-devel
mailing list