[gtk: 1/2] wayland: avoid set_cursor() when unchanged or invisible




commit 992f092968585c08a4a8277494913a694effa771
Author: wisp3rwind <wisp3rwind posteo eu>
Date:   Fri Nov 13 13:01:56 2020 +0100

    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 than
    rescaling to 1.

 gdk/wayland/gdkdevice-wayland.c | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index c975c2069d..1ebc0f79dc 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -4312,6 +4312,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)
     {
@@ -4319,6 +4322,8 @@ pointer_surface_update_scale (GdkDevice *device)
       scale = MAX (scale, output_scale);
     }
 
+  if (pointer->current_output_scale == scale)
+    return;
   pointer->current_output_scale = scale;
 
   gdk_wayland_device_update_surface_cursor (device);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]