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




commit cf7f7df10c3999516f466018cb6f21b469137913
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 then
    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 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)


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