Handle cursor theme changes for cached cursors which are not associated

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.
This commit is contained in:
Matthias Clasen 2005-06-17 17:26:24 +00:00 committed by Matthias Clasen
parent c96795ffb3
commit beb73ece8f
7 changed files with 101 additions and 20 deletions

View 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

View 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

View 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

View 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))
return;
cursor = _gdk_x11_window_get_cursor (GDK_WINDOW (value));
if (!cursor)
return;
private = (GdkCursorPrivate *) cursor;
xdisplay = (Display *)data;
xdisplay = GDK_DISPLAY_XDISPLAY (private->display);
if (private->serial == theme_serial)
return;
private->serial = theme_serial;
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;

View 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++)

View 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;

View 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))
{