[gtk/wip/matthiasc/popup2: 99/108] dnd: Drop a gratitious use of global coordinates



commit 96333e4934c30058827e824bacf85aed818f64d1
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 24 22:35:07 2019 -0400

    dnd: Drop a gratitious use of global coordinates

 gtk/gtkdnd.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index a2603bb36c..fd7543bb52 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -401,9 +401,7 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel,
     case GDK_DRAG_MOTION:
     case GDK_DROP_START:
       {
-        GdkSurface *surface;
-        gint tx, ty;
-        double x_root, y_root;
+        double x, y;
         gboolean found;
 
         if (event_type == GDK_DROP_START)
@@ -418,16 +416,13 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel,
               }
           }
 
-        surface = gtk_widget_get_surface (toplevel);
-
-        gdk_surface_get_position (surface, &tx, &ty);
-        gdk_event_get_root_coords (event, &x_root, &y_root);
+        gdk_event_get_coords (event, &x, &y);
 
         found = gtk_drop_find_widget (toplevel,
                                       drop,
                                       info,
-                                      x_root - tx,
-                                      y_root - ty,
+                                      x,
+                                      y,
                                       time,
                                       (event_type == GDK_DRAG_MOTION) ?
                                       gtk_drag_dest_motion :
@@ -452,7 +447,7 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel,
 }
 
 static gboolean
-gtk_drop_find_widget (GtkWidget           *widget,
+gtk_drop_find_widget (GtkWidget           *event_widget,
                       GdkDrop             *drop,
                       GtkDragDestInfo     *info,
                       gint                 x,
@@ -460,18 +455,19 @@ gtk_drop_find_widget (GtkWidget           *widget,
                       guint32              time,
                       GtkDragDestCallback  callback)
 {
-  if (!gtk_widget_get_mapped (widget) ||
-      !gtk_widget_get_sensitive (widget))
+  GtkWidget *widget;
+
+  if (!gtk_widget_get_mapped (event_widget) ||
+      !gtk_widget_get_sensitive (event_widget))
     return FALSE;
 
-  /* Get the widget at the pointer coordinates and travel up
-   * the widget hierarchy from there.
-   */
-  widget = _gtk_widget_find_at_coords (gtk_widget_get_surface (widget),
-                                       x, y, &x, &y);
+  widget = gtk_widget_pick (event_widget, x, y);
+
   if (!widget)
     return FALSE;
 
+  gtk_widget_translate_coordinates (event_widget, widget, x, y, &x, &y);
+
   while (widget)
     {
       GtkWidget *parent;


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