[gtk+/xi2: 146/148] GtkAboutDialog: Set device cursor on links.



commit 6e9e520319cb0a4b2340f1dd9f582645a40d9737
Author: Carlos Garnacho <carlos gnome org>
Date:   Wed Dec 9 23:37:47 2009 +0100

    GtkAboutDialog: Set device cursor on links.

 gtk/gtkaboutdialog.c |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c
index af7f2cd..ea6bfa5 100644
--- a/gtk/gtkaboutdialog.c
+++ b/gtk/gtkaboutdialog.c
@@ -197,6 +197,7 @@ static void                 follow_if_link                  (GtkAboutDialog
 							     GtkTextIter        *iter);
 static void                 set_cursor_if_appropriate       (GtkAboutDialog     *about,
 							     GtkTextView        *text_view,
+                                                             GdkDevice          *device,
 							     gint                x,
 							     gint                y);
 static void                 display_credits_dialog          (GtkWidget          *button,
@@ -1897,6 +1898,7 @@ text_view_event_after (GtkWidget      *text_view,
 static void
 set_cursor_if_appropriate (GtkAboutDialog *about,
 			   GtkTextView    *text_view,
+                           GdkDevice      *device,
 			   gint            x,
 			   gint            y)
 {
@@ -1926,9 +1928,9 @@ set_cursor_if_appropriate (GtkAboutDialog *about,
       priv->hovering_over_link = hovering_over_link;
 
       if (hovering_over_link)
-        gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->hand_cursor);
+        gdk_window_set_device_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), device, priv->hand_cursor);
       else
-        gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), priv->regular_cursor);
+        gdk_window_set_device_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), device, priv->regular_cursor);
     }
 
   if (tags) 
@@ -1946,7 +1948,7 @@ text_view_motion_notify_event (GtkWidget *text_view,
                                          GTK_TEXT_WINDOW_WIDGET,
                                          event->x, event->y, &x, &y);
 
-  set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), x, y);
+  set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), event->device, x, y);
 
   gdk_event_request_motions (event);
 
@@ -1959,15 +1961,27 @@ text_view_visibility_notify_event (GtkWidget          *text_view,
                                    GdkEventVisibility *event,
                                    GtkAboutDialog     *about)
 {
+  GdkDeviceManager *device_manager;
+  GdkDisplay *display;
+  GList *devices, *d;
   gint wx, wy, bx, by;
 
-  gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
+  display = gdk_drawable_get_display (event->window);
+  device_manager = gdk_display_get_device_manager (display);
+  devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
 
-  gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view), 
-                                         GTK_TEXT_WINDOW_WIDGET,
-                                         wx, wy, &bx, &by);
+  for (d = devices; d; d = d->next)
+    {
+      GdkDevice *dev = d->data;
 
-  set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), bx, by);
+      gdk_window_get_device_position (text_view->window, dev, &wx, &wy, NULL);
+
+      gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
+                                             GTK_TEXT_WINDOW_WIDGET,
+                                             wx, wy, &bx, &by);
+
+      set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view), dev, bx, by);
+    }
 
   return FALSE;
 }



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