sourceid in XIRawEvents

Peter Hutterer peter.hutterer at who-t.net
Mon Feb 14 16:31:06 PST 2011


On Mon, Feb 14, 2011 at 11:13:19AM +0100, Mark Dokter wrote:
> On 02/13/2011 11:57 PM, Peter Hutterer wrote:
> > On Fri, Feb 11, 2011 at 03:51:39PM +0100, Mark Dokter wrote:
> >> I noticed that the sourceid field in XIRawEvents is 0 while the
> >> XIDeviceEvent sourceid field gets filled with the correct id of a slave
> >> device.
> >> The code I wrote some time ago uses raw events and now I realized that I
> >> have the requirement to know from which device the event came from.
> >> Is this a bug or is this a deliberate behaviour (since the xinput
> >> utility also avoids printing source ids of raw events) ?
> > 
> > ah, crud. this is a bug in the XI2 spec or the library, depending how you
> > see it. the protocol doesn't provide a sourceid. I guess the libXi headers
> > have it thanks to a copy/paste bug.
> 
> Since you can listen for raw events on the master device, the events
> should have source and device ids. If you listen for them on a slave
> device, it makes sense, that there should be only one id field.
> 
> > 
> > Having said that, I can't remember the exact reason why raw events don't
> > have a source ID. Other than that the idea of raw events is that you'd be
> > listening to the SDs, not the MDs, and thus the need for sourceid isn't
> > really there.
> > 
> Thats too bad. I used the raw events because they provide motion deltas,
> so I don't have to calculate them myself, but I listen to master
> devices, since I want to work with pointers and not the devices.
> When I listen for raw events on the master device, they have the
> deviceid of that master device. So there seems to be no other options
> than either switching to XIDeviceEvents or listening to each slave device?
> What I'm actually trying to achieve is, finding out if the event came
> from the xtest slave device or not.

XIDeviceEvents won't have the deltas though, and they'll be capped at the
screen. There's no real solution for you at this point other than listening
for SDs. If you keep track of XIHierarchyEvents and register for raw events
on XIAllDevices you can work around this bug though.

note that I'm planning to add this to XI2.1 so that raw events from MDs have
the sourceid set but this won't be part of the server until 1.11.

Cheers,
  Peter



More information about the xorg mailing list