After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 623377 - Add API to know the hardware input device that triggered an event
Add API to know the hardware input device that triggered an event
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: X11
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 340720
 
 
Reported: 2010-07-02 12:21 UTC by Carlos Garnacho
Modified: 2010-12-22 19:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to implement gdk_event_get_source_device() (25.27 KB, patch)
2010-07-02 12:21 UTC, Carlos Garnacho
none Details | Review
Updated patch (26.35 KB, patch)
2010-07-08 11:52 UTC, Carlos Garnacho
needs-work Details | Review

Description Carlos Garnacho 2010-07-02 12:21:32 UTC
Created attachment 165100 [details] [review]
Patch to implement gdk_event_get_source_device()

I'm attaching a patch that adds gdk_event_get_source_device(), this may be used in most situations to know the slave device that triggered an event (Done through XIEvent->sourceid in xi2).

There are some situations where the slave device can't be guessed though, namely synthesized crossing events around a grab/ungrab operation, the master device will be used as the source device in these cases where no slave device can be obtained.
Comment 1 Matthias Clasen 2010-07-06 18:44:19 UTC
Do we really need this, separately from gdk_event_get_device ? Will you ever have
source_device != device,  both != NULL ?
Comment 2 Carlos Garnacho 2010-07-08 11:52:07 UTC
Created attachment 165469 [details] [review]
Updated patch

Hrm, I indeed didn't hook this properly so this info goes through _gdk_windowing_got_event(), this is an updated patch that does that.

I think there is a need for this API whenever some widget/app is interested in the slave device actually triggering the event, and not the master device proxying it. Given this device hierarchy:

⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ N-Trig MultiTouch                       	id=12	[slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad              	id=19	[slave  pointer  (2)]

gdk_event_get_device() would return the VCP, meanwhile gdk_event_get_source_device() would get me either the touchscreen or the touchpad devices, depending on which one I'm dealing with. One use case I can think of in GTK+ would be to hypothetically trigger kinetic scrolling if the source device is a touchscreen, OTOH we might need more GdkInputSource types and better heuristics before getting there...
Comment 3 Matthias Clasen 2010-08-05 04:23:31 UTC
Ok, makes sense to me now.
And the patch looks reasonable. One question I have is if you really need to store two device pointers in the event. Shouldn't it be possible to infer the master device from the slave ?
Comment 4 Matthias Clasen 2010-08-25 05:07:57 UTC
Ping ?
Comment 5 Carlos Garnacho 2010-09-08 16:39:41 UTC
(In reply to comment #3)
> Ok, makes sense to me now.
> And the patch looks reasonable. One question I have is if you really need to
> store two device pointers in the event. Shouldn't it be possible to infer the
> master device from the slave ?

Hmm, that's a very good point, I'll rework the patch to get there, it'll possibly require some other API call though, or making gdk_device_get_associated_device() return the master device for a slave, what'd be most preferred?
Comment 6 Matthias Clasen 2010-09-08 16:43:54 UTC
Maybe we want to split it into two clearly different functions, like
get_master_device / get_slave_device ? 
Or maybe having one get_associated_device function that always gives the other end of the master-slave pair is fine.
Not sure whats better.
Comment 7 Carlos Garnacho 2010-09-08 18:36:21 UTC
Thinking about it, having separate functions might make sense, since on one hand, master devices may have several slaves, thus requiring something like:

GList * gdk_device_get_slave_devices (GdkDevice *device);

And on the other hand, slave devices may not have a master devices (thus they are floating). gdk_device_get_associated_device() may remain for getting the paired pointer/keyboard for a device, being only useful for master devices, as it is now. This way the meaning of the returned device wouldn't vary.
Comment 8 Matthias Clasen 2010-09-19 05:57:13 UTC
Do you have a new patch ?
Comment 9 Matthias Clasen 2010-09-27 04:32:17 UTC
Ping
Comment 10 Matthias Clasen 2010-12-22 19:23:53 UTC
This has been done a while ago.