window: Store unconstrained_rect everytime a size is requested

Currently the stored unconstrained_rect is only ever updated if there
was a move, resize or state change according to the move_resize_internal
implementation.  For Wayland windows however resizes or state changes
are done in two steps, first the new configuration is sent to the client
and then once client acknowledges it, it is set on the mutter side in
another move_resize_internal call. Only the second call would result in
the unconstrained_rect being updated.

This started causing problems when unfullscreening windows was
immediately followed by a strut change. These strut changes started
happening in gnome-shell due to the visibility of the panel now being
considered for the struts and the presence of a fullscreen causing it to
be hidden until unfullscreen. In this situation first the unfullscreen
would resize the window to its pre-fullscreen size as expected, but then
the strut change triggers another window resize. This window resize is
based on the stored unconstrained_rect, which is still at the fullscreen
size because the unfullscreen resize only has sent its configuration,
but it has not been acknowledged yet. As a result the strut change
causes a resize to the fullscreen size which due to the constraints now
looks like a maximized window.

To fix this always update the unconstrained_rect when the requested size
has changed, but not when a previous request has been acknowledged
unless it is originating from the client itself.

If this included the move_resize_internal call from acknowledging the
size as well, it would be possible for this to be delayed long enough on
the client side to overwrite an intermediate resize originating from
mutter. And if this did not include resizes originating from the client,
clients would not be able to set an initial window size.

Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/1973

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2066>
This commit is contained in:
Sebastian Keller 2021-10-27 23:44:47 +02:00 committed by Marge Bot
parent 8eb268fc3b
commit 6902a724ce

View File

@ -4162,8 +4162,13 @@ meta_window_move_resize_internal (MetaWindow *window,
g_signal_emit (window, window_signals[SIZE_CHANGED], 0);
}
if (moved_or_resized || did_placement)
window->unconstrained_rect = unconstrained_rect;
/* Only update the stored size when requested but not when a
* (potentially outdated) request completes */
if (!(flags & META_MOVE_RESIZE_WAYLAND_FINISH_MOVE_RESIZE) ||
flags & META_MOVE_RESIZE_WAYLAND_CLIENT_RESIZE)
{
window->unconstrained_rect = unconstrained_rect;
}
if ((moved_or_resized ||
did_placement ||