[gtk/gtk-3-24: 1/2] wayland/window: Only update the scale if on any outputs




commit b86e6bc38aaa56a8f443cafb09efbdb9e02d99b8
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Jan 7 19:30:27 2022 +0100

    wayland/window: Only update the scale if on any outputs
    
    If we ended up on no output at all, keep the HiDPI scale as is, as it
    likely means we were on a workspace that was switched away from. By
    keeping the same scale, we avoid unnecessary scale changes that would
    otherwise take place if the scale when on monitors would end up being
    more than 1.

 gdk/wayland/gdkwindow-wayland.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index f73ef302e5..943a570e86 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -753,12 +753,23 @@ window_update_scale (GdkWindow *window)
       return;
     }
 
-  scale = 1;
-  for (l = impl->display_server.outputs; l != NULL; l = l->next)
+  if (!impl->display_server.outputs)
     {
-      guint32 output_scale =
-        _gdk_wayland_screen_get_output_scale (display_wayland->screen, l->data);
-      scale = MAX (scale, output_scale);
+      scale = impl->scale;
+    }
+  else
+    {
+      scale = 1;
+      for (l = impl->display_server.outputs; l != NULL; l = l->next)
+        {
+          struct wl_output *output = l->data;
+          uint32_t output_scale;
+
+          output_scale =
+            _gdk_wayland_screen_get_output_scale (display_wayland->screen,
+                                                  output);
+          scale = MAX (scale, output_scale);
+        }
     }
 
   /* Notify app that scale changed */


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