From c40a8121bc4ff50d857a84c2559571b414bea4ee Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Sat, 1 Nov 2003 20:53:18 +0000 Subject: [PATCH] added a GdkDisplay parameter and added the convenience function 2003-11-01 Sven Neumann * app/widgets/gimpcursor.[ch] (gimp_cursor_new): added a GdkDisplay parameter and added the convenience function gimp_cursor_set(). * app/display/gimpdisplayshell-cursor.c * app/tools/gimpcurvestool.c * app/widgets/gimpdialogfactory.c: changed accordingly. --- ChangeLog | 10 +++++++++ app/display/gimpdisplayshell-cursor.c | 25 ++++++++--------------- app/tools/gimpcurvestool.c | 11 ++++------ app/widgets/gimpcursor.c | 25 +++++++++++++++++++++-- app/widgets/gimpcursor.h | 11 ++++++---- app/widgets/gimpdialogfactory.c | 29 +++++++++++++++++++-------- 6 files changed, 73 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index bd9c036a4f..482408857b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-11-01 Sven Neumann + + * app/widgets/gimpcursor.[ch] (gimp_cursor_new): added a + GdkDisplay parameter and added the convenience function + gimp_cursor_set(). + + * app/display/gimpdisplayshell-cursor.c + * app/tools/gimpcurvestool.c + * app/widgets/gimpdialogfactory.c: changed accordingly. + 2003-11-01 Manish Singh * app/core/gimppalette.c (gimp_palette_load): plug a memleak diff --git a/app/display/gimpdisplayshell-cursor.c b/app/display/gimpdisplayshell-cursor.c index a9cdbc64e4..cd55701471 100644 --- a/app/display/gimpdisplayshell-cursor.c +++ b/app/display/gimpdisplayshell-cursor.c @@ -78,16 +78,13 @@ gimp_display_shell_set_override_cursor (GimpDisplayShell *shell, (shell->using_override_cursor && shell->override_cursor != cursor_type)) { - GdkCursor *cursor; - shell->override_cursor = cursor_type; shell->using_override_cursor = TRUE; - cursor = gimp_cursor_new (cursor_type, - GIMP_TOOL_CURSOR_NONE, - GIMP_CURSOR_MODIFIER_NONE); - gdk_window_set_cursor (shell->canvas->window, cursor); - gdk_cursor_unref (cursor); + gimp_cursor_set (shell->canvas, + cursor_type, + GIMP_TOOL_CURSOR_NONE, + GIMP_CURSOR_MODIFIER_NONE); } } @@ -110,7 +107,7 @@ gimp_display_shell_unset_override_cursor (GimpDisplayShell *shell) void gimp_display_shell_update_cursor (GimpDisplayShell *shell, - gint x, + gint x, gint y) { GimpImage *gimage; @@ -158,8 +155,8 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell, t_y >= gimage->height) { info_window_update_extended (shell->gdisp, -1, -1); - } - else + } + else { info_window_update_extended (shell->gdisp, t_x, t_y); } @@ -202,16 +199,10 @@ gimp_display_shell_real_set_cursor (GimpDisplayShell *shell, shell->cursor_modifier != modifier || always_install) { - GdkCursor *cursor; - shell->current_cursor = cursor_type; shell->tool_cursor = tool_cursor; shell->cursor_modifier = modifier; - cursor = gimp_cursor_new (cursor_type, - tool_cursor, - modifier); - gdk_window_set_cursor (shell->canvas->window, cursor); - gdk_cursor_unref (cursor); + gimp_cursor_set (shell->canvas, cursor_type, tool_cursor, modifier); } } diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c index 3118c41213..15dcbc3638 100644 --- a/app/tools/gimpcurvestool.c +++ b/app/tools/gimpcurvestool.c @@ -1019,15 +1019,12 @@ curves_graph_events (GtkWidget *widget, if (new_cursor != cursor_type) { - GdkCursor *cursor; - cursor_type = new_cursor; - cursor = gimp_cursor_new (cursor_type, - GIMP_TOOL_CURSOR_NONE, - GIMP_CURSOR_MODIFIER_NONE); - gdk_window_set_cursor (c_tool->graph->window, cursor); - gdk_cursor_unref (cursor); + gimp_cursor_set (c_tool->graph, + cursor_type, + GIMP_TOOL_CURSOR_NONE, + GIMP_CURSOR_MODIFIER_NONE); } curves_update (c_tool, XRANGE_TOP); diff --git a/app/widgets/gimpcursor.c b/app/widgets/gimpcursor.c index 6de4071fb5..b443a8112e 100644 --- a/app/widgets/gimpcursor.c +++ b/app/widgets/gimpcursor.c @@ -420,7 +420,8 @@ create_cursor_bitmaps (GimpBitmapCursor *bmcursor) } GdkCursor * -gimp_cursor_new (GimpCursorType cursor_type, +gimp_cursor_new (GdkDisplay *display, + GimpCursorType cursor_type, GimpToolCursorType tool_cursor, GimpCursorModifier modifier) { @@ -437,10 +438,11 @@ gimp_cursor_new (GimpCursorType cursor_type, static GdkGC *gc = NULL; static GdkColor fg, bg; + g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); g_return_val_if_fail (cursor_type < GIMP_LAST_CURSOR_ENTRY, NULL); if (cursor_type <= GDK_LAST_CURSOR) - return gdk_cursor_new_for_display (gdk_display_get_default (), cursor_type); + return gdk_cursor_new_for_display (display, cursor_type); g_return_val_if_fail (cursor_type >= GIMP_MOUSE_CURSOR, NULL); @@ -563,3 +565,22 @@ gimp_cursor_new (GimpCursorType cursor_type, return cursor; } + +void +gimp_cursor_set (GtkWidget *widget, + GimpCursorType cursor_type, + GimpToolCursorType tool_cursor, + GimpCursorModifier modifier) +{ + GdkCursor *cursor; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (GTK_WIDGET_REALIZED (widget)); + + cursor = gimp_cursor_new (gtk_widget_get_display (widget), + cursor_type, + tool_cursor, + modifier); + gdk_window_set_cursor (widget->window, cursor); + gdk_cursor_unref (cursor); +} diff --git a/app/widgets/gimpcursor.h b/app/widgets/gimpcursor.h index 783f660d51..fe081f8f4b 100644 --- a/app/widgets/gimpcursor.h +++ b/app/widgets/gimpcursor.h @@ -19,11 +19,14 @@ #ifndef __GIMP_CURSOR_H__ #define __GIMP_CURSOR_H__ -#ifdef __GNUC__ -#warning FIXME: need a new API that passes a display for gimp_cursor_new() -#endif -GdkCursor * gimp_cursor_new (GimpCursorType curtype, +GdkCursor * gimp_cursor_new (GdkDisplay *display, + GimpCursorType cursor_type, + GimpToolCursorType tool_cursor, + GimpCursorModifier modifier); + +void gimp_cursor_set (GtkWidget *widget, + GimpCursorType cursor_type, GimpToolCursorType tool_cursor, GimpCursorModifier modifier); diff --git a/app/widgets/gimpdialogfactory.c b/app/widgets/gimpdialogfactory.c index 12f83a7d19..cc560c9714 100644 --- a/app/widgets/gimpdialogfactory.c +++ b/app/widgets/gimpdialogfactory.c @@ -1303,12 +1303,9 @@ gimp_dialog_factories_set_busy_foreach (gconstpointer key, GimpDialogFactory *factory, gpointer data) { - GdkCursor *cursor; - GList *list; - - cursor = gimp_cursor_new (GDK_WATCH, - GIMP_TOOL_CURSOR_NONE, - GIMP_CURSOR_MODIFIER_NONE); + GdkDisplay *display = NULL; + GdkCursor *cursor = NULL; + GList *list; for (list = factory->open_dialogs; list; list = g_list_next (list)) { @@ -1316,11 +1313,27 @@ gimp_dialog_factories_set_busy_foreach (gconstpointer key, GTK_WIDGET_TOPLEVEL (list->data) && GTK_WIDGET_VISIBLE (list->data)) { - gdk_window_set_cursor (GTK_WIDGET (list->data)->window, cursor); + GtkWidget *widget = GTK_WIDGET (list->data); + + if (!display || display != gtk_widget_get_display (widget)) + { + display = gtk_widget_get_display (widget); + + if (cursor) + gdk_cursor_unref (cursor); + + cursor = gimp_cursor_new (display, + GDK_WATCH, + GIMP_TOOL_CURSOR_NONE, + GIMP_CURSOR_MODIFIER_NONE); + } + + gdk_window_set_cursor (widget->window, cursor); } } - gdk_cursor_unref (cursor); + if (cursor) + gdk_cursor_unref (cursor); } static void