[gtk+/gtk-2-24] Bug 658767 - Drag and Drop NSEvent capture is racy
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] Bug 658767 - Drag and Drop NSEvent capture is racy
- Date: Sun, 25 Sep 2011 19:30:11 +0000 (UTC)
commit d08d4507c9516f1ec701147cfa2992912e9339b6
Author: John Ralls <jralls ceridwen us>
Date: Sat Sep 24 18:19:56 2011 -0700
Bug 658767 - Drag and Drop NSEvent capture is racy
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).
gtk/gtkdnd-quartz.c | 43 +++++++++++++++++++++++++++++++++++--------
1 files changed, 35 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c
index a2dcc1f..87b32e6 100644
--- a/gtk/gtkdnd-quartz.c
+++ b/gtk/gtkdnd-quartz.c
@@ -1127,13 +1127,44 @@ gtk_drag_begin_internal (GtkWidget *widget,
{
GtkDragSourceInfo *info;
GdkDragContext *context;
- NSWindow *nswindow;
-
- context = gdk_drag_begin (NULL, NULL);
+ NSWindow *nswindow = get_toplevel_nswindow (widget);
+ NSPoint point = {0, 0};
+ gdouble x, y;
+ double time = (double)g_get_real_time ();
+ NSEvent *nsevent;
+ NSTimeInterval nstime;
+
+ if (event)
+ {
+ if (gdk_event_get_coords (event, &x, &y))
+ {
+ point.x = x;
+ point.y = y;
+ }
+ time = (double)gdk_event_get_time (event);
+ }
+ nstime = [[NSDate dateWithTimeIntervalSince1970: time / 1000] timeIntervalSinceReferenceDate];
+ nsevent = [NSEvent mouseEventWithType: NSLeftMouseDown
+ location: point
+ modifierFlags: 0
+ timestamp: nstime
+ windowNumber: [nswindow windowNumber]
+ context: [nswindow graphicsContext]
+ eventNumber: 0
+ clickCount: 1
+ pressure: 0.0 ];
+
+ GdkWindow *window = [[nswindow contentView] gdkWindow];
+ g_return_val_if_fail(nsevent != NULL, NULL);
+
+ context = gdk_drag_begin (window, NULL);
+ g_return_val_if_fail( context != NULL, NULL);
context->is_source = TRUE;
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;
@@ -1200,10 +1231,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 */
g_idle_add_full (G_PRIORITY_HIGH_IDLE, gtk_drag_begin_idle, context, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]