GNOME Bugzilla – Bug 665637
[patch] should use gdk_copy_event to copy events
Last modified: 2021-05-17 13:40:30 UTC
The events passed for pointer events on items are copied by simply assigning structs instead of using gdk_event_copy. Because of this, a call to gdk_get_source_device(event) fails on these events. There's probably more similar gdk calls that won't work with these pointer events. The attached patch fixes this.
Created attachment 202884 [details] [review] patch to use gdk_copy_event for copying an event
Damien, may we push this to master?
Yes, that patch looks OK. Do we need to worry about other places we create our own GdkEvent: update_pointer_item()/initialize_crossing_event() generate_grab_broken() goo_canvas_grab_focus() The last 2 probably don't matter, but I'm not sure about the first one. Why is gdk_get_source_device(event) needed?
gdk_get_source_device tells you what device generated the event. I need it to differentiate between input from a wacom tablet and mouse input. Personally, I would *always* use the dedicated copy function, because it also copies the private data. In fact, all gdk_event_* functions assume that the're actually dealing with a GdkEventPrivate struct, so they will read/write after the GdkEvent struct. This may be a security risk, especially since the new event is on the stack. So it is very unsafe to not use gdk_event_copy. I would definitely recommend using it everywhere.
I've applied the patch. It might be good to think about how to handle multiple mouse/keyboard devices at some point. I'm not sure how you're supposed to deal with grabs from multiple devices, or enter/leave notifies. It would be difficult to keep track of them all.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/goocanvas/-/issues/29.