diff --git a/gdk/quartz/GdkQuartzNSWindow.c b/gdk/quartz/GdkQuartzNSWindow.c index 87206ca990..848ed50daf 100644 --- a/gdk/quartz/GdkQuartzNSWindow.c +++ b/gdk/quartz/GdkQuartzNSWindow.c @@ -656,6 +656,7 @@ update_context_from_dragging_info (id sender) - (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation { GdkEvent *event; + GdkScreen *screen; g_assert (_gdk_quartz_drag_source_context != NULL); @@ -664,6 +665,33 @@ update_context_from_dragging_info (id sender) event->dnd.send_event = FALSE; event->dnd.context = g_object_ref (_gdk_quartz_drag_source_context); + screen = gdk_window_get_screen (event.dnd.window); + + if (screen) + { + GList* windows, *list; + gint gx, gy; + + event.dnd.context->dest_window = NULL; + + windows = gdk_screen_get_toplevel_windows (screen); + _gdk_quartz_window_nspoint_to_gdk_xy (aPoint, &gx, &gy); + + for (list = windows; list; list = list->next) + { + GdkWindow* win = (GdkWindow*) list->data; + gint wx, wy; + gint ww, wh; + + gdk_window_get_root_origin (win, &wx, &wy); + ww = gdk_window_get_width (win); + wh = gdk_window_get_height (win); + + if (gx > wx && gy > wy && gx <= wx + ww && gy <= wy + wh) + event.dnd.context->dest_window = win; + } + } + gdk_event_set_device (event, gdk_drag_context_get_device (_gdk_quartz_drag_source_context));