GNOME Bugzilla – Bug 658767
Drag and Drop NSEvent capture is racy
Last modified: 2011-10-09 18:41:44 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.
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).
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.
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 on attachment 196829 [details] [review] Revised patch to handle non-motion (including NULL) events Committed to gtk-2-24, gtk-3-2, and master.