From c06c7bdc6ad532a6123f86b5136d3ffbaa167409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 4 Feb 2023 16:57:26 +0100 Subject: [PATCH 1/2] 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 --- gdk/wayland/gdkcursor-wayland.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gdk/wayland/gdkcursor-wayland.c b/gdk/wayland/gdkcursor-wayland.c index c3e97286e1..0cb21093ff 100644 --- a/gdk/wayland/gdkcursor-wayland.c +++ b/gdk/wayland/gdkcursor-wayland.c @@ -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; From ee211544132d96b0cdceda717d4e77d52b715a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 4 Sep 2023 15:15:51 +0200 Subject: [PATCH 2/2] gdk/wayland: Use g_warning_once for cursor scale mismatches. --- gdk/wayland/gdkcursor-wayland.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/gdk/wayland/gdkcursor-wayland.c b/gdk/wayland/gdkcursor-wayland.c index 0cb21093ff..e3eef3d2e2 100644 --- a/gdk/wayland/gdkcursor-wayland.c +++ b/gdk/wayland/gdkcursor-wayland.c @@ -224,7 +224,6 @@ _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) { @@ -240,13 +239,9 @@ _gdk_wayland_cursor_get_buffer (GdkCursor *cursor, while ((image->width % cursor_scale != 0) || (image->height % cursor_scale != 0)) { - 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; - } + g_warning_once (G_STRLOC " cursor image size (%dx%d) not an integer" + "multiple of scale (%d)", image->width, image->height, + cursor_scale); cursor_scale--; }