summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwisp3rwind <wisp3rwind@posteo.eu>2020-11-13 13:01:56 +0100
committerwisp3rwind <wisp3rwind@posteo.eu>2020-11-13 16:20:02 +0100
commitcf7f7df10c3999516f466018cb6f21b469137913 (patch)
tree452085b5ac5e4fd8effe649c03bac7f6ab05069f
parent016e8c55ab924c9ef4d32c8cb06253b1dc1be60d (diff)
downloadgtk+-cf7f7df10c3999516f466018cb6f21b469137913.tar.gz
wayland: avoid set_cursor() when unchanged or invisible
In pointer_surface_update_scale(), only rescale the cursor surface when the scale has actually changed and the cursor is on at least one output. fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3350 Right now, this issue is not completely understood, so it might also involve some questionable handling of cursor surface by sway/wlroots. However, irrespective of that issue, this patch avoids unnecessary calls to the compositor, and there should be no drawback: Whenever the pointer enters a new output, pointer_surface_update_scale() will be called again, such that correct scaling of the cursor is still ensured. There is a slight difference: When the cursor leaves the last output, previously the image was reset to scale factor 1. Now, it keeps whatever was last. That might be more sensible than the previous behaviour, assuming that it's likely that when the cursor enter an output again, it has the same scaling. Alternatively, if one cares about resource usage at this level, it might make more sense to destroy the surface then rescaling to 1.
-rw-r--r--gdk/wayland/gdkdevice-wayland.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 7d81eaff3b..e6f0f5193c 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -4598,6 +4598,9 @@ pointer_surface_update_scale (GdkDevice *device)
return;
}
+ if (!pointer->pointer_surface_outputs)
+ return;
+
scale = 1;
for (l = pointer->pointer_surface_outputs; l != NULL; l = l->next)
{
@@ -4607,6 +4610,8 @@ pointer_surface_update_scale (GdkDevice *device)
scale = MAX (scale, output_scale);
}
+ if (pointer->current_output_scale == scale)
+ return;
pointer->current_output_scale = scale;
if (pointer->cursor)