XInput2: getting window-relative coordinates?

Florian Echtler floe at butterbrot.org
Sat Apr 18 01:54:31 PDT 2009


> > 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.
Okay, sounds good. However, there seem to be some glitches hidden
somewhere. I'm running libXi, inputproto, xinput and xorg-server from
Peter's repo and libXext, libX11, libxcb, xproto, xcb-proto and
xextproto from master. The rest is from the Gentoo stable distro.

- for XI_Enter/XI_Leave, this looks as expected, with one exception.
  Here's what "xinput test-xi2" shows for those events:

  EVENT type 7
    windows: root 0x7e event 0x3600001 child 0x0
    mode: NotifyNormal (detail NotifyAncestor)
    flags:  [same screen]
    buttons:
    modifiers: locked 0x0 latched 0x0 base 0x0
    group: locked 0x0 latched 0x0 base 0x0
    root x/y:  134.00 / 243.00
    event x/y: 133.00 / 133.00

  Note that event x/y are equal. This is _always_ the case, and always
  corresponds to the window-local x coordinate. I grepped through libXi,
  but couldn't find anything obviously wrong. 

- for XI_Motion, the root x/y and event x/y fields are always (0/0) and
  (-372/-372), sometimes also (0/0) and (-1/-1). Should these fields be
  also valid for XI_Motion?

> 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.
Ah, okay. Does it matter whether I select AllDevices or
AllMasterDevices? Here's the code which I use to select my events:

FGAPI void FGAPIENTRY glutRegisterDevices() {

	XIDeviceEventMask mask;
	unsigned char flags[2] = { 0, 0 };

	Display* dpy = fgDisplay.Display;
	Window* win = glutGetXWindow();

	/* Select for motion events */
	mask.deviceid = AllMasterDevices;
	mask.mask_len = 2;
	mask.mask = flags;

	SetBit(mask.mask, XI_Enter);
	SetBit(mask.mask, XI_Motion);
	SetBit(mask.mask, XI_ButtonPress);
	SetBit(mask.mask, XI_ButtonRelease);
	SetBit(mask.mask, XI_Leave);

	XISelectEvent( dpy, *win, &mask, 1 );
}


Did I miss anything here?

Yours, Florian
-- 
0666 - Filemode of the Beast




More information about the xorg mailing list