quartz: Check if a drag ends inside a known window

If a drag ends inside a known window, set the dest_window field
in the drag context. This information is needed to implemented
notebook tab dragging.

https://bugzilla.gnome.org/show_bug.cgi?id=752638
This commit is contained in:
Matthias Clasen 2015-07-26 02:04:48 -04:00
parent 955c1c7734
commit 6d04183c5d

View File

@ -656,6 +656,7 @@ update_context_from_dragging_info (id <NSDraggingInfo> 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 <NSDraggingInfo> 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));