[gtk+/quartz-integration] Move the capture of the NSEvent to the beginning of gtk_drag_begin_internal as a weak (and probably



commit cc7319bfa9ba8b4116aa98e4a4c285fd69320af7
Author: John Ralls <jralls ceridwen us>
Date:   Fri Dec 31 17:21:41 2010 -0800

    Move the capture of the NSEvent to the beginning of gtk_drag_begin_internal as a weak (and probably vain) attempt to reduce the likelihood of a race condition.
    
    A better solution would notice that we're doing a drag in gdkevents and set everything up there where we know about the actual NSEvent.

 gtk/gtkdnd-quartz.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c
index 39a47a9..9bb3ae8 100644
--- a/gtk/gtkdnd-quartz.c
+++ b/gtk/gtkdnd-quartz.c
@@ -1115,7 +1115,12 @@ gtk_drag_begin_internal (GtkWidget         *widget,
 {
   GtkDragSourceInfo *info;
   GdkDragContext *context;
-  NSWindow *nswindow;
+/* FIXME: This is a bit of a race condition, because there's a fairly
+ * large delay between receiving a motion event and the application
+ * deciding that it's a drag during which time the NSWindow might have
+ * registered another NSEvent. */
+  NSWindow *nswindow = get_toplevel_nswindow (widget);
+  NSEvent *nsevent = [nswindow currentEvent];
 
   context = gdk_drag_begin (gtk_widget_get_window (widget), NULL);
 /* If we've already started a drag, gdk_drag_begin will return NULL;
@@ -1123,7 +1128,9 @@ gtk_drag_begin_internal (GtkWidget         *widget,
   g_return_val_if_fail( context != NULL, NULL);
 
   info = gtk_drag_get_source_info (context, TRUE);
-  
+  info->nsevent = nsevent;
+  [info->nsevent retain];
+
   info->source_widget = g_object_ref (widget);
   info->widget = g_object_ref (widget);
   info->target_list = target_list;
@@ -1166,9 +1173,6 @@ gtk_drag_begin_internal (GtkWidget         *widget,
 	  }
     }
 
-  nswindow = get_toplevel_nswindow (widget);
-  info->nsevent = [nswindow currentEvent];
-  [info->nsevent retain];
 
   /* drag will begin in an idle handler to avoid nested run loops */
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]