[gtk+/client-side-windows: 49/284] Implement cursors



commit 7b2b9a0219ed116d34250d4bed000467fdf3642e
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Dec 15 14:02:52 2008 +0100

    Implement cursors
---
 gdk/gdkdisplay.c   |   15 ++-------------
 gdk/gdkinternals.h |    3 +++
 gdk/gdkwindow.c    |   37 +++++++++++++++++++++++++++++--------
 3 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index ce07af7..44b8b88 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -737,17 +737,6 @@ generate_grab_broken_event (GdkWindow *window,
     }
 }
 
-static void
-set_window_under_pointer (GdkDisplay *display,
-			  GdkWindow *window)
-{
-  if (display->pointer_info.window_under_pointer)
-    g_object_unref (display->pointer_info.window_under_pointer);
-  display->pointer_info.window_under_pointer = window;
-  if (window)
-    g_object_ref (window);
-}
-
 void
 _gdk_display_set_has_pointer_grab (GdkDisplay *display,
 				   GdkWindow *window,
@@ -840,7 +829,7 @@ _gdk_display_set_has_pointer_grab (GdkDisplay *display,
       /* !owner_event Grabbing a window that we're not inside, current status is
 	 now NULL (i.e. outside grabbed window) */
       if (!owner_events && display->pointer_info.window_under_pointer != window)
-	set_window_under_pointer (display, NULL);
+	_gdk_display_set_window_under_pointer (display, NULL);
     }
 
   display->pointer_grab.window = window;
@@ -966,7 +955,7 @@ _gdk_display_unset_has_pointer_grab (GdkDisplay *display,
     }
 
   /* We're now ungrabbed, update the window_under_pointer */
-  set_window_under_pointer (display, pointer_window);
+  _gdk_display_set_window_under_pointer (display, pointer_window);
   
   if (implicit)
     generate_grab_broken_event (old_grab_window,
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index ca1be2e..ffa2237 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -527,6 +527,9 @@ void _gdk_syntesize_crossing_events (GdkDisplay                 *display,
 				     GdkModifierType             mask,
 				     guint32                     time_,
 				     GdkEvent                   *event_in_queue);
+void _gdk_display_set_window_under_pointer (GdkDisplay *display,
+					    GdkWindow *window);
+
 
 void _gdk_syntesize_crossing_events_for_geometry_change (GdkWindow *changed_window);
 
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 3b483e2..634d859 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -5927,6 +5927,17 @@ gdk_window_set_back_pixmap (GdkWindow *window,
     GDK_WINDOW_IMPL_GET_IFACE (private->impl)->set_back_pixmap (window, private->bg_pixmap);
 }
 
+static GdkCursor *
+get_cursor_for_window (GdkWindowObject *cursor_window)
+{
+  while (cursor_window->cursor == NULL &&
+	 cursor_window->parent != NULL &&
+	 cursor_window->parent->window_type != GDK_WINDOW_ROOT)
+    cursor_window = cursor_window->parent;
+
+  return cursor_window->cursor;
+}
+
 /**
  * gdk_window_set_cursor:
  * @window: a #GdkWindow
@@ -5943,10 +5954,12 @@ gdk_window_set_cursor (GdkWindow *window,
 		       GdkCursor *cursor)
 {
   GdkWindowObject *private;
+  GdkDisplay *display;
 
   g_return_if_fail (GDK_IS_WINDOW (window));
 
   private = (GdkWindowObject *) window;
+  display = gdk_drawable_get_display (window);
 
   if (private->cursor)
     {
@@ -5959,9 +5972,9 @@ gdk_window_set_cursor (GdkWindow *window,
       if (cursor)
 	private->cursor = gdk_cursor_ref (cursor);
 
-      /* TODO: Track this via pointer_window 
-	 GDK_WINDOW_IMPL_GET_IFACE (private->impl)->set_cursor (window, cursor);
-      */
+      if (is_parent_of (window, display->pointer_info.window_under_pointer))
+	GDK_WINDOW_IMPL_GET_IFACE (private->impl)->set_cursor (window,
+							       get_cursor_for_window (private));
     }
 }
 
@@ -7233,15 +7246,23 @@ get_pointer_window (GdkDisplay *display,
   return pointer_window;
 }
 
-static void
-set_window_under_pointer (GdkDisplay *display,
-			  GdkWindow *window)
+void
+_gdk_display_set_window_under_pointer (GdkDisplay *display,
+				       GdkWindow *window)
 {
+  GdkWindowObject *private;
+
+  private = (GdkWindowObject *)window;
+
   if (display->pointer_info.window_under_pointer)
     g_object_unref (display->pointer_info.window_under_pointer);
   display->pointer_info.window_under_pointer = window;
   if (window)
     g_object_ref (window);
+
+  if (window)
+    GDK_WINDOW_IMPL_GET_IFACE (private->impl)->set_cursor (window,
+							   get_cursor_for_window (private));
 }
 
 void
@@ -7273,7 +7294,7 @@ _gdk_syntesize_crossing_events_for_geometry_change (GdkWindow *changed_window)
 					  display->pointer_info.state,
 					  GDK_CURRENT_TIME,
 					  NULL);
-	  set_window_under_pointer (display, new_window_under_pointer);
+	  _gdk_display_set_window_under_pointer (display, new_window_under_pointer);
 	}
     }
 }
@@ -7370,7 +7391,7 @@ proxy_pointer_event (GdkDisplay                 *display,
 				      state, time_,
 				      source_event);
 
-      set_window_under_pointer (display, pointer_window);
+      _gdk_display_set_window_under_pointer (display, pointer_window);
     }
   else if (source_event->type == GDK_MOTION_NOTIFY)
     {



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