[gtk+/gtk-3-22] wayland: Fix a race condition with xdg_popup resize



commit 68188fc948a555e672bc8cbf927d9f691c3eacd9
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Fri Nov 25 14:24:52 2016 +0100

    wayland: Fix a race condition with xdg_popup resize
    
    When resizing an xdg_popup immediately after the initial mapping, there
    is a race condition between the client and the compositor which is
    processing the initial size given by the xdg_positioner, leading to the
    xdg_popup to be eventually of the wrong size.
    
    Only way to make sure the size is correct in that case is to hide and
    show the window again. Considering this occurs before the initial
    configure is processed, it should not be noticeable.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772505

 gdk/wayland/gdkwindow-wayland.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index 5f01d39..b6013a1 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -1014,13 +1014,30 @@ gdk_wayland_window_maybe_configure (GdkWindow *window,
                                     int        scale)
 {
   GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+  gboolean is_xdg_popup;
+  gboolean is_visible;
 
   if (window->width == width &&
       window->height == height &&
       impl->scale == scale)
     return;
 
+  /* For xdg_popup using an xdg_positioner, there is a race condition if
+   * the application tries to change the size after it's mapped, but before
+   * the initial configure is received, so hide and show the surface again
+   * force the new size onto the compositor. See bug #772505.
+   */
+
+  is_xdg_popup = (impl->display_server.xdg_popup != NULL);
+  is_visible = gdk_window_is_visible (window);
+
+  if (is_xdg_popup && is_visible && !impl->initial_configure_received)
+    gdk_window_hide (window);
+
   gdk_wayland_window_configure (window, width, height, scale);
+
+  if (is_xdg_popup && is_visible && !impl->initial_configure_received)
+    gdk_window_show (window);
 }
 
 static void


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