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
This commit is contained in:
Olivier Fourdan 2016-11-25 14:24:52 +01:00
parent 1e7178e66f
commit 83b54bab57

View File

@ -1001,13 +1001,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