1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 01:12:40 +02:00

Compare commits

...

1 Commits

Author SHA1 Message Date
Alx Sa
7e2dc9761c app/widgets: Add fallback for missing cursors
This patch checks to see if the cursor created
with gdk_cursor_new_for_display () is NULL
before trying to unreference it.
It also attempts to create a CSS fallback if the
cursor is NULL via gdk_cursor_new_from_name ().
2024-08-15 12:34:43 +00:00

View File

@@ -813,8 +813,33 @@ set_cursor (GimpCurveView *view,
GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (view));
GdkCursor *cursor = gdk_cursor_new_for_display (display, new_cursor);
/* If the user's theme doesn't have the cursor ID, we'll try a
* CSS fallback */
if (cursor == NULL)
{
switch (new_cursor)
{
case GDK_TCROSS:
cursor = gdk_cursor_new_from_name (display, "crosshair");
break;
case GDK_FLEUR:
cursor = gdk_cursor_new_from_name (display, "move");
break;
case GDK_X_CURSOR:
cursor = gdk_cursor_new_from_name (display, "not-allowed");
break;
case GDK_PENCIL:
cursor = gdk_cursor_new_from_name (display, "pointer");
break;
default:
break;
}
}
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (view)), cursor);
g_object_unref (cursor);
if (cursor)
g_object_unref (cursor);
view->cursor_type = new_cursor;
}