[gtk+/xi2: 653/1239] Add public gdk_window_set_device_cursor() function.



commit 11174838c98ae073fcb8220cafe235df7f8ca79a
Author: Carlos Garnacho <carlos lanedo com>
Date:   Thu Jul 30 19:02:47 2009 +0200

    Add public gdk_window_set_device_cursor() function.

 gdk/gdkinternals.h |    1 +
 gdk/gdkwindow.c    |   35 +++++++++++++++++++++++++++++++++++
 gdk/gdkwindow.h    |    3 +++
 3 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index e1e73fe..ce26c09 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -260,6 +260,7 @@ struct _GdkWindowObject
   GdkRegion *clip_region; /* Clip region (wrt toplevel) in window coords */
   GdkRegion *clip_region_with_children; /* Clip region in window coords */
   GdkCursor *cursor;
+  GHashTable *device_cursor;
   gint8 toplevel_window_type;
   guint synthesize_crossing_event_queued : 1;
   guint effective_visibility : 2;
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 7dc3164..9fa22bf 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -565,6 +565,9 @@ gdk_window_finalize (GObject *object)
   if (obj->cursor)
     gdk_cursor_unref (obj->cursor);
 
+  if (obj->device_cursor)
+    g_hash_table_destroy (obj->device_cursor);
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -1249,6 +1252,8 @@ gdk_window_new (GdkWindow     *parent,
 				  (attributes->cursor) :
 				  NULL));
 
+  private->device_cursor = g_hash_table_new_full (NULL, NULL, NULL,
+                                                  (GDestroyNotify) gdk_cursor_unref);
   return window;
 }
 
@@ -6971,6 +6976,36 @@ gdk_window_set_cursor (GdkWindow *window,
     }
 }
 
+void
+gdk_window_set_device_cursor (GdkWindow *window,
+                              GdkDevice *device,
+                              GdkCursor *cursor)
+{
+  GdkWindowObject *private;
+  GdkDisplay *display;
+
+  g_return_if_fail (GDK_IS_WINDOW (window));
+  g_return_if_fail (GDK_IS_DEVICE (window));
+
+  private = (GdkWindowObject *) window;
+  display = gdk_drawable_get_display (window);
+
+  if (!cursor)
+    g_hash_table_remove (private->device_cursor, device);
+  else
+    g_hash_table_replace (private->device_cursor, device, cursor);
+
+  if (!GDK_WINDOW_DESTROYED (window))
+    {
+      GdkPointerWindowInfo *pointer_info;
+
+      pointer_info = _gdk_display_get_pointer_info (display, device);
+
+      if (_gdk_window_event_parent_of (window, pointer_info->window_under_pointer))
+        update_cursor (display, device);
+    }
+}
+
 /**
  * gdk_window_get_geometry:
  * @window: a #GdkWindow
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index a1d3184..6018d06 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -517,6 +517,9 @@ void	      gdk_window_set_back_pixmap (GdkWindow	  *window,
 					  gboolean	   parent_relative);
 void	      gdk_window_set_cursor	 (GdkWindow	  *window,
 					  GdkCursor	  *cursor);
+void	      gdk_window_set_device_cursor (GdkWindow	  *window,
+                                            GdkDevice     *device,
+                                            GdkCursor	  *cursor);
 void	      gdk_window_get_user_data	 (GdkWindow	  *window,
 					  gpointer	  *data);
 void	      gdk_window_get_geometry	 (GdkWindow	  *window,



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