[gtk+/xi2] _gtk_tooltip_focus_in(): Use gdk_window_get_device_position().



commit d74438d7d4d3f17632c998f86b9d59cef0ca4e2d
Author: Carlos Garnacho <carlos gnome org>
Date:   Tue Dec 22 02:19:25 2009 +0100

    _gtk_tooltip_focus_in(): Use gdk_window_get_device_position().
    
    This function is either called from keybindings or focus in events,
    so the device for the current event is get in order to get the
    associated pointer position.

 gtk/gtktooltip.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index 8ccd363..88a1b7a 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -1131,6 +1131,7 @@ _gtk_tooltip_focus_in (GtkWidget *widget)
   gboolean return_value = FALSE;
   GdkDisplay *display;
   GtkTooltip *tooltip;
+  GdkDevice *device;
 
   /* Get current tooltip for this display */
   display = gtk_widget_get_display (widget);
@@ -1141,12 +1142,23 @@ _gtk_tooltip_focus_in (GtkWidget *widget)
   if (!tooltip || !tooltip->keyboard_mode_enabled)
     return;
 
+  device = gtk_get_current_event_device ();
+
+  if (device && device->source == GDK_SOURCE_KEYBOARD)
+    device = gdk_device_get_associated_device (device);
+
+  /* This function should be called by either a focus in event,
+   * or a key binding. In either case there should be a device.
+   */
+  if (!device)
+    return;
+
   if (tooltip->keyboard_widget)
     g_object_unref (tooltip->keyboard_widget);
 
   tooltip->keyboard_widget = g_object_ref (widget);
 
-  gdk_window_get_pointer (widget->window, &x, &y, NULL);
+  gdk_window_get_device_position (widget->window, device, &x, &y, NULL);
 
   return_value = gtk_tooltip_run_requery (&widget, tooltip, &x, &y);
   if (!return_value)



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