[gtk+/xi2: 638/1239] Add set_device_cursor() to GdkWindowImpl. Implement it for X11 windows.



commit b2eea12f758d2e85813330565a44b97f578b4569
Author: Carlos Garnacho <carlos lanedo com>
Date:   Tue Jul 28 22:02:57 2009 +0200

    Add set_device_cursor() to GdkWindowImpl. Implement it for X11 windows.

 gdk/gdkwindowimpl.h     |    3 +++
 gdk/x11/gdkwindow-x11.c |   34 ++++++++++++++++++++++++++++++++++
 gdk/x11/gdkwindow-x11.h |    2 ++
 3 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h
index ad1ae6b..f219aa0 100644
--- a/gdk/gdkwindowimpl.h
+++ b/gdk/gdkwindowimpl.h
@@ -77,6 +77,9 @@ struct _GdkWindowImplIface
   
   void         (* set_cursor)           (GdkWindow       *window,
                                          GdkCursor       *cursor);
+  void         (* set_device_cursor)    (GdkWindow       *window,
+                                         GdkDevice       *device,
+                                         GdkCursor       *cursor);
 
   void         (* get_geometry)         (GdkWindow       *window,
                                          gint            *x,
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index e83706b..dec864e 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -142,6 +142,8 @@ static void
 gdk_window_impl_x11_init (GdkWindowImplX11 *impl)
 {  
   impl->toplevel_window_type = -1;
+  impl->device_cursor = g_hash_table_new_full (NULL, NULL, NULL,
+                                               (GDestroyNotify) gdk_cursor_unref);
 }
 
 GdkToplevelX11 *
@@ -206,6 +208,8 @@ gdk_window_impl_x11_finalize (GObject *object)
   if (window_impl->cursor)
     gdk_cursor_unref (window_impl->cursor);
 
+  g_hash_table_destroy (window_impl->device_cursor);
+
   G_OBJECT_CLASS (gdk_window_impl_x11_parent_class)->finalize (object);
 }
 
@@ -2734,6 +2738,35 @@ gdk_window_x11_set_cursor (GdkWindow *window,
     }
 }
 
+static void
+gdk_window_x11_set_device_cursor (GdkWindow *window,
+                                  GdkDevice *device,
+                                  GdkCursor *cursor)
+{
+  GdkWindowObject *private;
+  GdkCursorPrivate *cursor_private;
+  GdkWindowImplX11 *impl;
+
+  g_return_if_fail (GDK_IS_WINDOW (window));
+  g_return_if_fail (GDK_IS_DEVICE (device));
+
+  private = (GdkWindowObject *) window;
+  impl = GDK_WINDOW_IMPL_X11 (private->impl);
+  cursor_private = (GdkCursorPrivate *) cursor;
+
+  if (!cursor)
+    g_hash_table_remove (impl->device_cursor, device);
+  else
+    {
+      _gdk_x11_cursor_update_theme (cursor);
+      g_hash_table_replace (impl->device_cursor,
+                            device, gdk_cursor_ref (cursor));
+    }
+
+  if (!GDK_WINDOW_DESTROYED (window))
+    GDK_DEVICE_GET_CLASS (device)->set_window_cursor (device, window, cursor);
+}
+
 GdkCursor *
 _gdk_x11_window_get_cursor (GdkWindow *window)
 {
@@ -5578,6 +5611,7 @@ gdk_window_impl_iface_init (GdkWindowImplIface *iface)
   iface->reparent = gdk_window_x11_reparent;
   iface->clear_region = gdk_window_x11_clear_region;
   iface->set_cursor = gdk_window_x11_set_cursor;
+  iface->set_device_cursor = gdk_window_x11_set_device_cursor;
   iface->get_geometry = gdk_window_x11_get_geometry;
   iface->get_root_coords = gdk_window_x11_get_root_coords;
   iface->get_pointer = gdk_window_x11_get_pointer;
diff --git a/gdk/x11/gdkwindow-x11.h b/gdk/x11/gdkwindow-x11.h
index 9a7f2ae..762f104 100644
--- a/gdk/x11/gdkwindow-x11.h
+++ b/gdk/x11/gdkwindow-x11.h
@@ -60,6 +60,8 @@ struct _GdkWindowImplX11
 
   GdkToplevelX11 *toplevel;	/* Toplevel-specific information */
   GdkCursor *cursor;
+  GHashTable *device_cursor;
+
   gint8 toplevel_window_type;
   guint no_bg : 1;	        /* Set when the window background is temporarily
 				 * unset during resizing and scaling */



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