wayland/cursor: Make sure the cached cursor has the right size

The cache key is just the name of the cursor, so if a previously added
cursor had e.g. scale == 1, if we ask for a new cursor with scale == 2,
we might still fetch the scale == 1 cursor from the cache. Avoid this by
making sure the scale of the cached one is correct.

If it isn't, load the cursor as normal, and update the cache entry with
the new properly scaled cursor.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/1183
This commit is contained in:
Jonas Ådahl 2019-01-08 18:43:29 +01:00
parent d31107c4fe
commit a907552df9

View File

@ -342,7 +342,7 @@ _gdk_wayland_display_get_cursor_for_name_with_scale (GdkDisplay *display,
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
wayland_cursor = g_hash_table_lookup (display_wayland->cursor_cache, name);
if (wayland_cursor)
if (wayland_cursor && wayland_cursor->scale == scale)
return GDK_CURSOR (g_object_ref (wayland_cursor));
wayland_cursor = g_object_new (GDK_TYPE_WAYLAND_CURSOR,
@ -369,9 +369,9 @@ _gdk_wayland_display_get_cursor_for_name_with_scale (GdkDisplay *display,
}
/* Insert into cache. */
g_hash_table_insert (display_wayland->cursor_cache,
wayland_cursor->name,
g_object_ref (wayland_cursor));
g_hash_table_replace (display_wayland->cursor_cache,
wayland_cursor->name,
g_object_ref (wayland_cursor));
return GDK_CURSOR (wayland_cursor);
}