]> Pileus Git - ~andy/gtk/commitdiff
Bug 607628 - DnD operation doesn't work when using offscreen
authorMichael Natterer <mitch@gimp.org>
Wed, 26 May 2010 15:09:11 +0000 (17:09 +0200)
committerMichael Natterer <mitch@gimp.org>
Wed, 26 May 2010 15:21:09 +0000 (17:21 +0200)
Turn find_widget_under_pointer() into internal API
_gtk_widget_find_at_coords() which is needed for fixing above
bug. This should actually be a public utility function, and will be
moved to another file when its final API has been decided.
(cherry picked from commit c4b1bbf3e201099e5fed38d7a60b343662b88b21)

gtk/gtktooltip.c
gtk/gtktooltip.h

index d5a301be4e56c3bcc1c3da9ab2225856504ebeec..67c2f6c9a05c16b88b8cd73bac965aa601b6e2a3 100644 (file)
@@ -647,14 +647,18 @@ window_to_alloc (GtkWidget *dest_widget,
 /* Translates coordinates from window relative (x, y) to
  * allocation relative (x, y) of the returned widget.
  */
-static GtkWidget *
-find_widget_under_pointer (GdkWindow *window,
-                          gint      *x,
-                          gint      *y)
+GtkWidget *
+_gtk_widget_find_at_coords (GdkWindow *window,
+                            gint       window_x,
+                            gint       window_y,
+                            gint      *widget_x,
+                            gint      *widget_y)
 {
   GtkWidget *event_widget;
   struct ChildLocation child_loc = { NULL, NULL, 0, 0 };
 
+  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
+
   gdk_window_get_user_data (window, (void **)&event_widget);
 
   if (!event_widget)
@@ -663,12 +667,12 @@ find_widget_under_pointer (GdkWindow *window,
 #ifdef DEBUG_TOOLTIP
   g_print ("event window %p (belonging to %p (%s))  (%d, %d)\n",
           window, event_widget, gtk_widget_get_name (event_widget),
-          *x, *y);
+          window_x, window_y);
 #endif
 
   /* Coordinates are relative to event window */
-  child_loc.x = *x;
-  child_loc.y = *y;
+  child_loc.x = window_x;
+  child_loc.y = window_y;
 
   /* We go down the window hierarchy to the widget->window,
    * coordinates stay relative to the current window.
@@ -725,14 +729,13 @@ find_widget_under_pointer (GdkWindow *window,
       gtk_widget_translate_coordinates (container, event_widget,
                                        child_loc.x, child_loc.y,
                                        &child_loc.x, &child_loc.y);
-
     }
 
   /* We return (x, y) relative to the allocation of event_widget. */
-  if (x)
-    *x = child_loc.x;
-  if (y)
-    *y = child_loc.y;
+  if (widget_x)
+    *widget_x = child_loc.x;
+  if (widget_y)
+    *widget_y = child_loc.y;
 
   return event_widget;
 }
@@ -750,11 +753,9 @@ find_topmost_widget_coords_from_event (GdkEvent *event,
   GtkWidget *tmp;
 
   gdk_event_get_coords (event, &dx, &dy);
-  tx = dx;
-  ty = dy;
 
   /* Returns coordinates relative to tmp's allocation. */
-  tmp = find_widget_under_pointer (event->any.window, &tx, &ty);
+  tmp = _gtk_widget_find_at_coords (event->any.window, dx, dy, &tx, &ty);
 
   if (!tmp)
     return NULL;
@@ -1084,8 +1085,9 @@ gtk_tooltip_show_tooltip (GdkDisplay *display)
       tooltip->last_x = tx;
       tooltip->last_y = ty;
 
-      pointer_widget = tooltip_widget = find_widget_under_pointer (window,
-                                                                  &x, &y);
+      pointer_widget = tooltip_widget = _gtk_widget_find_at_coords (window,
+                                                                    x, y,
+                                                                    &x, &y);
     }
 
   if (!tooltip_widget)
index ac310c908d399e2c1ef535049b05e87a7248f23c..7fa4a2203df16d2007d8ce579efb1200a622a3b8 100644 (file)
@@ -66,6 +66,12 @@ void _gtk_tooltip_toggle_keyboard_mode   (GtkWidget          *widget);
 void _gtk_tooltip_handle_event           (GdkEvent           *event);
 void _gtk_tooltip_hide                   (GtkWidget          *widget);
 
+GtkWidget * _gtk_widget_find_at_coords   (GdkWindow          *window,
+                                          gint                window_x,
+                                          gint                window_y,
+                                          gint               *widget_x,
+                                          gint               *widget_y);
+
 G_END_DECLS
 
 #endif /* __GTK_TOOLTIP_H__ */