XInput2: getting window-relative coordinates?

Peter Hutterer peter.hutterer at
Fri Apr 17 15:58:20 PDT 2009

On Fri, Apr 17, 2009 at 05:45:15PM +0200, Florian Echtler wrote:
> > after a bit more fiddling, I now have MPX and XI2 up and running. My
> > software is receiving the new XI2 input events fine; however, I've
> > noticed that the valuators are always in screen coordinates. Is there a
> > way to get them in window coordinates, or do I need to use XGetGeometry
> > to convert them?
> More experimentation with my code and with "xinput test-xi2" now has me
> totally confused. I created two master pointers, one is attached to an
> USB mouse, the other to a Synaptics touchpad. 
> The first one (controlled by mouse) reports absolute screen coordinates
> with evtype == XI_Motion - the values range from (0,0) to (xres,yres).
> While window coordinates would be nice, that is about what I expect.
> However, the second one (controlled by touchpad) reports values in the
> range (1472,1408) to (5472,4448). This is also reported in the Xorg.log
> by the synaptics driver. How can I map these to screen coordinates? As
> the pointer still moves in screen coordinates, the mapping must already
> exist somewhere, I assume.. 
> I know that this is quite beta still, so I'd be very grateful about some
> hints..

right, so the rule for coordinates is:
event_x,event_y, root_x, root_y are in absolute screen coordinates. or should
be anyway.

the data in *valuators OTOH is in device-coordinates. this may be screen
coordinates for relative devices, and device coordinates for absolute devices.
You need to get the axis information through XIQueryDevice() first, and do the
scaling on the client-side if you need it.

for what you're trying to do, root_x/y should do.

unless I screwed up majorly...

More information about the xorg mailing list