gdk/wayland: Don't fall back directly to 1 for mismatched cursor sizes.

Try to find a lower scale that still works. In most cases this will end
up with a 2-scaled cursor rather than 3-scaled cursor.

Fixes #5567
This commit is contained in:
Emilio Cobos Álvarez 2023-02-04 16:57:26 +01:00
parent 292893f9d7
commit c06c7bdc6a
No known key found for this signature in database
GPG Key ID: E1152D0994E4BF8A

View File

@ -224,6 +224,7 @@ _gdk_wayland_cursor_get_buffer (GdkCursor *cursor,
{
struct wl_cursor_image *image;
int cursor_scale;
gboolean warned = FALSE;
if (image_index >= wayland_cursor->wl_cursor->image_count)
{
@ -236,13 +237,17 @@ _gdk_wayland_cursor_get_buffer (GdkCursor *cursor,
image = wayland_cursor->wl_cursor->images[image_index];
cursor_scale = wayland_cursor->scale;
if ((image->width % cursor_scale != 0) ||
(image->height % cursor_scale != 0))
while ((image->width % cursor_scale != 0) ||
(image->height % cursor_scale != 0))
{
g_warning (G_STRLOC " cursor image size (%dx%d) not an integer"
"multiple of scale (%d)", image->width, image->height,
cursor_scale);
cursor_scale = 1;
if (!warned)
{
g_warning (G_STRLOC " cursor image size (%dx%d) not an integer"
"multiple of scale (%d)", image->width, image->height,
cursor_scale);
warned = TRUE;
}
cursor_scale--;
}
*hotspot_x = image->hotspot_x / cursor_scale;