wayland: Be more careful about scale-factor
authorMatthias Clasen <mclasen@redhat.com>
Sun, 2 Apr 2023 17:23:19 +0000 (13:23 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 2 Apr 2023 17:23:19 +0000 (13:23 -0400)
Only emit notify::scale-factor if it actually
changes. This potentially avoids a lot of work
in GTK (reloading icons, etc).

gdk/wayland/gdksurface-wayland.c

index ca27f653731c2c0f4cf5a635ab4ddaadf98ae39e..0cebc0047447e606167f6b0af96e3aedeba573e0 100644 (file)
@@ -261,11 +261,12 @@ gdk_wayland_surface_update_size (GdkSurface               *surface,
                                  const GdkFractionalScale *scale)
 {
   GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
-  gboolean width_changed, height_changed, scale_changed;
+  gboolean width_changed, height_changed, scale_changed, scale_factor_changed;
 
   width_changed = surface->width != width;
   height_changed = surface->height != height;
   scale_changed = !gdk_fractional_scale_equal (&impl->scale, scale);
+  scale_factor_changed = gdk_fractional_scale_to_int (&impl->scale) != gdk_fractional_scale_to_int (scale);
 
   if (!width_changed && !height_changed && !scale_changed)
     return;
@@ -295,10 +296,9 @@ gdk_wayland_surface_update_size (GdkSurface               *surface,
   if (height_changed)
     g_object_notify (G_OBJECT (surface), "height");
   if (scale_changed)
-    {
-      g_object_notify (G_OBJECT (surface), "scale-factor");
-      g_object_notify (G_OBJECT (surface), "scale");
-    }
+    g_object_notify (G_OBJECT (surface), "scale");
+  if (scale_factor_changed)
+    g_object_notify (G_OBJECT (surface), "scale-factor");
 
   _gdk_surface_update_size (surface);
 }