From 9f89421ef5abfe5143a777aa33eee308e81a7055 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 3 Oct 2023 13:54:38 +0200 Subject: [PATCH] backends: Attempt a fallback to 'default' cursor on failed lookups While we should ideally have a sensible cursor theme, handle the case of cursor themes that lack certain cursor names, and fallback to the 'default' cursor in those cases. The 'grey rectangle' fallback is still left, in case we even fail to load a 'default' cursor. Part-of: --- src/backends/meta-cursor-sprite-xcursor.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/backends/meta-cursor-sprite-xcursor.c b/src/backends/meta-cursor-sprite-xcursor.c index 4794b89f0..42d1884a6 100644 --- a/src/backends/meta-cursor-sprite-xcursor.c +++ b/src/backends/meta-cursor-sprite-xcursor.c @@ -157,17 +157,22 @@ static XcursorImages * load_cursor_on_client (MetaCursor cursor, int scale) { XcursorImages *xcursor_images; - int fallback_size; + int fallback_size, i; + /* Set a 'default' fallback */ + MetaCursor cursors[] = { cursor, META_CURSOR_DEFAULT }; if (cursor == META_CURSOR_BLANK) return create_blank_cursor_images (); - xcursor_images = - XcursorLibraryLoadImages (translate_meta_cursor (cursor), - meta_prefs_get_cursor_theme (), - meta_prefs_get_cursor_size () * scale); - if (xcursor_images) - return xcursor_images; + for (i = 0; i < G_N_ELEMENTS (cursors); i++) + { + xcursor_images = + XcursorLibraryLoadImages (translate_meta_cursor (cursors[i]), + meta_prefs_get_cursor_theme (), + meta_prefs_get_cursor_size () * scale); + if (xcursor_images) + return xcursor_images; + } g_warning_once ("No cursor theme available, please install a cursor theme");