[gtk: 1/2] wayland/surface: Only update the scale if on any outputs




commit 6efcc028067afbe442aed16b654794dd6bcea5d5
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Jan 7 19:28:36 2022 +0100

    wayland/surface: 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/gdksurface-wayland.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index c2d4ea464c..3c046b5ea2 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -780,11 +780,22 @@ gdk_wayland_surface_update_scale (GdkSurface *surface)
       return;
     }
 
-  scale = 1;
-  for (l = impl->display_server.outputs; l != NULL; l = l->next)
+  if (!impl->display_server.outputs)
     {
-      guint32 output_scale = gdk_wayland_display_get_output_scale (display_wayland, 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_display_get_output_scale (display_wayland,
+                                                               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]