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 658767 - Drag and Drop NSEvent capture is racy
Drag and Drop NSEvent capture is racy
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Quartz
3.1.x
Other Mac OS
: Normal normal
: ---
Assigned To: gtk-quartz maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2011-09-11 22:51 UTC by John Ralls
Modified: 2011-10-09 18:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Create a new NSMouseLeftDown event (2.03 KB, patch)
2011-09-12 16:38 UTC, John Ralls
reviewed Details | Review
Revised patch to handle non-motion (including NULL) events (2.25 KB, patch)
2011-09-17 20:23 UTC, John Ralls
committed Details | Review

Description John Ralls 2011-09-11 22:51:51 UTC
gtk_drag_begin_internal currently obtains the current nsevent for the currently-focused NSWindow. This turns out to be a bit racy, particularly on the slow iBook I use for PPC building and testing.
Comment 1 John Ralls 2011-09-12 16:38:32 UTC
Created attachment 196277 [details] [review]
Create a new NSMouseLeftDown event

Create a synthetic NSMouseLeftDown to store in the GtkQuartzDragSourceInfo rather than relying on the NSWindow's latest event being the right one (or the right kind).
Comment 2 Kristian Rietveld 2011-09-17 05:27:37 UTC
Review of attachment 196277 [details] [review]:

If the comment below is addressed, this is fine for 2-24 and master.

::: gtk/gtkdnd-quartz.c
@@ +1119,3 @@
+		      modifierFlags: 0
+		      timestamp: event->motion.time
+		      windowNumber: [nswindow windowNumber]

I am a bit worried by this being dependent on GdkEventMotion.  Theoretically, the API user can feed any event to gtk_drag_begin(), which will end up here in gtk_drag_begin_internal().

So I recommend to:
  * Instead of accessing event->motion.{x,y}, use gdk_event_get_coords()
  * Instead of accessing event->motion.time, use gdk_event_get_time()

Also, if event is a button event, I would use event->button.button and translate that to the appropriate NS*MouseDown value instead of hardcoding NSLeftMouseDown. For GTK+ master, gdk_event_get_button() can be used instead of a direct field access and this function will handle the check whether event is a button event for you.
Comment 3 Kristian Rietveld 2011-09-17 05:27:39 UTC
Review of attachment 196277 [details] [review]:

If the comment below is addressed, this is fine for 2-24 and master.

::: gtk/gtkdnd-quartz.c
@@ +1119,3 @@
+		      modifierFlags: 0
+		      timestamp: event->motion.time
+		      windowNumber: [nswindow windowNumber]

I am a bit worried by this being dependent on GdkEventMotion.  Theoretically, the API user can feed any event to gtk_drag_begin(), which will end up here in gtk_drag_begin_internal().

So I recommend to:
  * Instead of accessing event->motion.{x,y}, use gdk_event_get_coords()
  * Instead of accessing event->motion.time, use gdk_event_get_time()

Also, if event is a button event, I would use event->button.button and translate that to the appropriate NS*MouseDown value instead of hardcoding NSLeftMouseDown. For GTK+ master, gdk_event_get_button() can be used instead of a direct field access and this function will handle the check whether event is a button event for you.
Comment 4 John Ralls 2011-09-17 20:23:49 UTC
Created attachment 196829 [details] [review]
Revised patch to handle non-motion (including NULL) events

From http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html :
"dragImage:at:offset:event:pasteboard:source:slideBack:
...
  event
    The left-mouse down event that triggered the dragging operation."

According to the docs, the event can be NULL, so I guess I should check that, too. Revised patch addresses that/
Comment 5 John Ralls 2011-10-09 18:41:32 UTC
Comment on attachment 196829 [details] [review]
Revised patch to handle non-motion (including NULL) events

Committed to gtk-2-24, gtk-3-2, and master.