wayland: Do not resize with the same size
authorOlivier Fourdan <ofourdan@redhat.com>
Mon, 4 Apr 2016 12:55:38 +0000 (14:55 +0200)
committerOlivier Fourdan <ofourdan@redhat.com>
Tue, 5 Apr 2016 16:22:40 +0000 (18:22 +0200)
gnome-control-center is calling gtk_window_resize() on configure-event
signals which leads to a busy loop.

Avoids such a busy loop by not re-configuring a window with the same
size, unless this is coming from and xdg-shell configure.

bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=764374

gdk/wayland/gdkwindow-wayland.c

index 46255ef2775c172be52bb1fb3741347e4d7085b2..8f944723e5ff120791102df60f416179c48b663a 100644 (file)
@@ -168,10 +168,10 @@ struct _GdkWindowImplWaylandClass
   GdkWindowImplClass parent_class;
 };
 
-static void gdk_wayland_window_configure (GdkWindow *window,
-                                          int        width,
-                                          int        height,
-                                          int        scale);
+static void gdk_wayland_window_maybe_configure (GdkWindow *window,
+                                                int        width,
+                                                int        height,
+                                                int        scale);
 
 static void maybe_set_gtk_surface_dbus_properties (GdkWindow *window);
 static void maybe_set_gtk_surface_modal (GdkWindow *window);
@@ -571,7 +571,7 @@ window_update_scale (GdkWindow *window)
     }
 
   /* Notify app that scale changed */
-  gdk_wayland_window_configure (window, window->width, window->height, scale);
+  gdk_wayland_window_maybe_configure (window, window->width, window->height, scale);
 }
 
 static void
@@ -926,6 +926,22 @@ gdk_wayland_window_configure (GdkWindow *window,
   _gdk_wayland_display_deliver_event (display, event);
 }
 
+static void
+gdk_wayland_window_maybe_configure (GdkWindow *window,
+                                    int        width,
+                                    int        height,
+                                    int        scale)
+{
+  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+  if (window->width == width &&
+      window->height == height &&
+      impl->scale == scale)
+    return;
+
+  gdk_wayland_window_configure (window, width, height, scale);
+}
+
 static void
 gdk_wayland_window_sync_parent (GdkWindow *window,
                                 GdkWindow *parent)
@@ -1936,7 +1952,7 @@ gdk_window_wayland_move_resize (GdkWindow *window,
    * just move the window - don't update its size
    */
   if (width > 0 && height > 0)
-    gdk_wayland_window_configure (window, width, height, impl->scale);
+    gdk_wayland_window_maybe_configure (window, width, height, impl->scale);
 }
 
 static void
@@ -2744,7 +2760,7 @@ gdk_wayland_window_set_shadow_width (GdkWindow *window,
     (impl->margin_left + impl->margin_right) + (left + right);
   new_height = window->height -
     (impl->margin_top + impl->margin_bottom) + (top + bottom);
-  gdk_wayland_window_configure (window, new_width, new_height, impl->scale);
+  gdk_wayland_window_maybe_configure (window, new_width, new_height, impl->scale);
 
   impl->margin_left = left;
   impl->margin_right = right;