]> Pileus Git - ~andy/gtk/commitdiff
Handle cursor theme changes for cached cursors which are not associated
authorMatthias Clasen <mclasen@redhat.com>
Fri, 17 Jun 2005 17:26:24 +0000 (17:26 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 17 Jun 2005 17:26:24 +0000 (17:26 +0000)
2005-06-17  Matthias Clasen  <mclasen@redhat.com>

* gdk/x11/gdkprivate-x11.h:
* gdk/x11/gdkcursor-x11.c: Handle cursor theme changes
for cached cursors which are not associated with a window
at the time of the theme change, by storing a serial
number in each cursor, and updating the theme_serial
counter whenever the cursor theme changes.

* gdk/x11/gdkcursor-x11.c (_gdk_x11_cursor_update_theme):
Private function to update a cursor to the current
cursor theme if necessary.

* gdk/x11/gdkmain-x11.c (gdk_pointer_grab):
* gdk/x11/gdkwindow-x11.c (gdk_window_set_cursor): Call
_gdk_x11_cursor_update_theme() here.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gdk/x11/gdkcursor-x11.c
gdk/x11/gdkmain-x11.c
gdk/x11/gdkprivate-x11.h
gdk/x11/gdkwindow-x11.c

index 7b454440071bbdce9e1e984b1a5634ab6a1b06da..f605227dbd79ef28db50d3e8026647e1b701e2bc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2005-06-17  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/x11/gdkprivate-x11.h: 
+       * gdk/x11/gdkcursor-x11.c: Handle cursor theme changes
+       for cached cursors which are not associated with a window
+       at the time of the theme change, by storing a serial
+       number in each cursor, and updating the theme_serial 
+       counter whenever the cursor theme changes.
+       
+       * gdk/x11/gdkcursor-x11.c (_gdk_x11_cursor_update_theme): 
+       Private function to update a cursor to the current
+       cursor theme if necessary.
+
+       * gdk/x11/gdkmain-x11.c (gdk_pointer_grab): 
+       * gdk/x11/gdkwindow-x11.c (gdk_window_set_cursor): Call
+       _gdk_x11_cursor_update_theme() here.
+
 2005-06-17  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkcairo.c (gdk_cairo_set_source_pixbuf): Fix
index 7b454440071bbdce9e1e984b1a5634ab6a1b06da..f605227dbd79ef28db50d3e8026647e1b701e2bc 100644 (file)
@@ -1,3 +1,20 @@
+2005-06-17  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/x11/gdkprivate-x11.h: 
+       * gdk/x11/gdkcursor-x11.c: Handle cursor theme changes
+       for cached cursors which are not associated with a window
+       at the time of the theme change, by storing a serial
+       number in each cursor, and updating the theme_serial 
+       counter whenever the cursor theme changes.
+       
+       * gdk/x11/gdkcursor-x11.c (_gdk_x11_cursor_update_theme): 
+       Private function to update a cursor to the current
+       cursor theme if necessary.
+
+       * gdk/x11/gdkmain-x11.c (gdk_pointer_grab): 
+       * gdk/x11/gdkwindow-x11.c (gdk_window_set_cursor): Call
+       _gdk_x11_cursor_update_theme() here.
+
 2005-06-17  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkcairo.c (gdk_cairo_set_source_pixbuf): Fix
index 7b454440071bbdce9e1e984b1a5634ab6a1b06da..f605227dbd79ef28db50d3e8026647e1b701e2bc 100644 (file)
@@ -1,3 +1,20 @@
+2005-06-17  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/x11/gdkprivate-x11.h: 
+       * gdk/x11/gdkcursor-x11.c: Handle cursor theme changes
+       for cached cursors which are not associated with a window
+       at the time of the theme change, by storing a serial
+       number in each cursor, and updating the theme_serial 
+       counter whenever the cursor theme changes.
+       
+       * gdk/x11/gdkcursor-x11.c (_gdk_x11_cursor_update_theme): 
+       Private function to update a cursor to the current
+       cursor theme if necessary.
+
+       * gdk/x11/gdkmain-x11.c (gdk_pointer_grab): 
+       * gdk/x11/gdkwindow-x11.c (gdk_window_set_cursor): Call
+       _gdk_x11_cursor_update_theme() here.
+
 2005-06-17  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/gdkcairo.c (gdk_cairo_set_source_pixbuf): Fix
index ccc757ff6b8667b573cbe981f076a26da44d21b2..4ebeb7be3c3dfbd52dd80bacb26ef3be6a9839c1 100644 (file)
@@ -46,6 +46,7 @@
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include "gdkalias.h"
 
+static guint theme_serial = 0;
 
 /**
  * gdk_cursor_new_for_display:
@@ -134,6 +135,8 @@ gdk_cursor_new_for_display (GdkDisplay    *display,
   private->display = display;
   private->xcursor = xcursor;
   private->name = NULL;
+  private->serial = theme_serial;
+
   cursor = (GdkCursor *) private;
   cursor->type = cursor_type;
   cursor->ref_count = 1;
@@ -238,6 +241,8 @@ gdk_cursor_new_from_pixmap (GdkPixmap      *source,
   private->display = display;
   private->xcursor = xcursor;
   private->name = NULL;
+  private->serial = theme_serial;
+
   cursor = (GdkCursor *) private;
   cursor->type = GDK_CURSOR_IS_PIXMAP;
   cursor->ref_count = 1;
@@ -390,27 +395,21 @@ gdk_cursor_get_image (GdkCursor *cursor)
   return pixbuf;
 }
 
-static void
-update_cursor (gpointer key,
-              gpointer value,
-              gpointer data)
+void
+_gdk_x11_cursor_update_theme (GdkCursor *cursor)
 {
   Display *xdisplay;
-  GdkCursor *cursor;
   GdkCursorPrivate *private;
   Cursor new_cursor = None;
 
-  if (!GDK_IS_WINDOW (value))
+  private = (GdkCursorPrivate *) cursor;
+  xdisplay = GDK_DISPLAY_XDISPLAY (private->display);
+         
+  if (private->serial == theme_serial)
     return;
 
-  cursor = _gdk_x11_window_get_cursor (GDK_WINDOW (value));
+  private->serial = theme_serial;
 
-  if (!cursor)
-    return;
-
-  private = (GdkCursorPrivate *) cursor;
-  xdisplay = (Display *)data;
-         
   if (private->xcursor != None)
     {
       if (cursor->type == GDK_CURSOR_IS_PIXMAP)
@@ -426,6 +425,24 @@ update_cursor (gpointer key,
     }
 }
 
+static void
+update_cursor (gpointer key,
+              gpointer value,
+              gpointer data)
+{
+  GdkCursor *cursor;
+
+  if (!GDK_IS_WINDOW (value))
+    return;
+
+  cursor = _gdk_x11_window_get_cursor (GDK_WINDOW (value));
+
+  if (!cursor)
+    return;
+  
+  _gdk_x11_cursor_update_theme (cursor);
+}
+
 /**
  * gdk_x11_display_set_cursor_theme:
  * @display: a #GdkDisplay
@@ -468,11 +485,12 @@ gdk_x11_display_set_cursor_theme (GdkDisplay  *display,
       old_theme && strcmp (old_theme, theme) == 0)
     return;
 
+  theme_serial++;
+
   XcursorSetTheme (xdisplay, theme);
   XcursorSetDefaultSize (xdisplay, size);
     
-  g_hash_table_foreach (display_x11->xid_ht, 
-                       update_cursor, xdisplay);
+  g_hash_table_foreach (display_x11->xid_ht, update_cursor, NULL);
 }
 
 #else
@@ -607,6 +625,8 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
   private->display = display;
   private->xcursor = xcursor;
   private->name = NULL;
+  private->serial = theme_serial;
+
   cursor = (GdkCursor *) private;
   cursor->type = GDK_CURSOR_IS_PIXMAP;
   cursor->ref_count = 1;
@@ -652,6 +672,8 @@ gdk_cursor_new_from_name (GdkDisplay  *display,
   private->display = display;
   private->xcursor = xcursor;
   private->name = g_strdup (name);
+  private->serial = theme_serial;
+
   cursor = (GdkCursor *) private;
   cursor->type = GDK_CURSOR_IS_PIXMAP;
   cursor->ref_count = 1;
index 21e369abf931efc0f207af6891c2c041c7208cbd..47b06cef77e2ac564fdbfa27c5e6ad738a23eec2 100644 (file)
@@ -194,8 +194,10 @@ gdk_pointer_grab (GdkWindow *        window,
   if (!cursor)
     xcursor = None;
   else
-    xcursor = cursor_private->xcursor;
-  
+    {
+      _gdk_x11_cursor_update_theme (cursor);
+      xcursor = cursor_private->xcursor;
+    }
   
   xevent_mask = 0;
   for (i = 0; i < _gdk_nenvent_masks; i++)
index ef96554ede9d851c38de2e884a9cfec68b8d8000..222ae6ba0fbd847e0b2f605502adc42d3c55f017 100644 (file)
@@ -76,6 +76,7 @@ struct _GdkCursorPrivate
   Cursor xcursor;
   GdkDisplay *display;
   gchar *name;
+  guint serial;
 };
 
 struct _GdkVisualPrivate
@@ -98,7 +99,7 @@ gint _gdk_send_xevent      (GdkDisplay *display,
 
 GType _gdk_gc_x11_get_type (void);
 
-gboolean _gdk_x11_have_render                 (GdkDisplay *display);
+gboolean _gdk_x11_have_render           (GdkDisplay *display);
 
 GdkGC *_gdk_x11_gc_new                  (GdkDrawable     *drawable,
                                         GdkGCValues     *values,
@@ -171,6 +172,8 @@ void _gdk_input_init            (GdkDisplay *display);
 PangoRenderer *_gdk_x11_renderer_get (GdkDrawable *drawable,
                                      GdkGC       *gc);
 
+void _gdk_x11_cursor_update_theme (GdkCursor *cursor);
+
 extern GdkDrawableClass  _gdk_x11_drawable_class;
 extern gboolean                 _gdk_use_xshm;
 extern const int         _gdk_nenvent_masks;
index 04a60881125b45d09b6b9e98752fbd2e02aae9ef..87957a3cf06b6b7b3b66e6429c8f0c00514b9a17 100644 (file)
@@ -2877,7 +2877,10 @@ gdk_window_set_cursor (GdkWindow *window,
   if (!cursor)
     xcursor = None;
   else
-    xcursor = cursor_private->xcursor;
+    {
+      _gdk_x11_cursor_update_theme (cursor);
+      xcursor = cursor_private->xcursor;
+    }
   
   if (!GDK_WINDOW_DESTROYED (window))
     {