[gtk+/gtk-2-24] quartz: Check if a drag ends inside a known window



commit 2ac4fe1b6609c3c2495ee8db0f39033999238422
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jul 26 02:15:31 2015 -0400

    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

 gdk/quartz/GdkQuartzWindow.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/gdk/quartz/GdkQuartzWindow.c b/gdk/quartz/GdkQuartzWindow.c
index 7c08712..bcd934e 100644
--- a/gdk/quartz/GdkQuartzWindow.c
+++ b/gdk/quartz/GdkQuartzWindow.c
@@ -617,6 +617,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);
 
@@ -625,6 +626,33 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
   event.dnd.send_event = FALSE;
   event.dnd.context = _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_func) (&event, _gdk_event_data);
 
   g_object_unref (event.dnd.window);


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