[gtk/resizing-fixes] wayland: Don't emit premature configure events




commit dc442ab3e5e42804b57760998e033d40b2ec16b9
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Aug 7 16:54:09 2020 -0400

    wayland: Don't emit premature configure events
    
    We should not emit configure events before we
    are realized - size changes at this point are
    not relevant.
    
    This gets rid of a mysterious emission of
    GdkSurface::size-changed (52, 52), that is happening
    when GtkWindow sets the shadow_width before the window
    is mapped.

 gdk/wayland/gdksurface-wayland.c | 46 ++++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 18 deletions(-)
---
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index 46dd4a3284..5d83feeccc 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -901,24 +901,6 @@ gdk_wayland_surface_finalize (GObject *object)
   G_OBJECT_CLASS (gdk_wayland_surface_parent_class)->finalize (object);
 }
 
-static void
-gdk_wayland_surface_resize (GdkSurface *surface,
-                            int         width,
-                            int         height,
-                            int         scale)
-{
-  GdkDisplay *display;
-  GdkEvent *event;
-
-  event = gdk_configure_event_new (surface, width, height);
-
-  gdk_wayland_surface_update_size (surface, width, height, scale);
-  _gdk_surface_update_size (surface);
-
-  display = gdk_surface_get_display (surface);
-  _gdk_wayland_display_deliver_event (display, event);
-}
-
 static gboolean
 is_realized_shell_surface (GdkSurface *surface)
 {
@@ -946,6 +928,34 @@ is_realized_popup (GdkSurface *surface)
           impl->display_server.zxdg_popup_v6);
 }
 
+static gboolean
+is_realized (GdkSurface *surface)
+{
+  return is_realized_toplevel (surface) ||
+         is_realized_popup (surface) ||
+         is_realized_shell_surface (surface);
+}
+
+static void
+gdk_wayland_surface_resize (GdkSurface *surface,
+                            int         width,
+                            int         height,
+                            int         scale)
+{
+  gdk_wayland_surface_update_size (surface, width, height, scale);
+  _gdk_surface_update_size (surface);
+
+  if (is_realized (surface))
+    {
+      GdkDisplay *display;
+      GdkEvent *event;
+
+      event = gdk_configure_event_new (surface, width, height);
+      display = gdk_surface_get_display (surface);
+      _gdk_wayland_display_deliver_event (display, event);
+    }
+}
+
 static void gdk_wayland_surface_show (GdkSurface *surface,
                                       gboolean    already_mapped);
 static void gdk_wayland_surface_hide (GdkSurface *surface);


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