From 03434e566a4aedd865cb642154abbe1e0cfe9a02 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Mon, 10 Jan 2022 20:11:47 +0100 Subject: [PATCH] wayland/subsurface: Ensure cached state recursivly gets applied on set_desync() Subsurfaces can be effectively synced indirectly via their ancestors. Right now such indirectly synced surfaces don't apply their cached state when their ancestor effectively becomes desync as by the time we call `parent_state_applied()` on them, they are considered as desync. Thus sligthly reoder things so when the ancestors becomes desync and applies its state, those surfaces still count as synced and will thus apply their cached state as well. While on it, add a check to prevent `set_desync()` to have side effects when the target surface is not currently synced. Part-of: --- src/wayland/meta-wayland-subsurface.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/wayland/meta-wayland-subsurface.c b/src/wayland/meta-wayland-subsurface.c index 7e996f4d3..1e9b65528 100644 --- a/src/wayland/meta-wayland-subsurface.c +++ b/src/wayland/meta-wayland-subsurface.c @@ -468,14 +468,18 @@ wl_subsurface_set_desync (struct wl_client *client, struct wl_resource *resource) { MetaWaylandSurface *surface = wl_resource_get_user_data (resource); - gboolean was_effectively_synchronized; + gboolean is_parent_effectively_synchronized; - was_effectively_synchronized = is_surface_effectively_synchronized (surface); - surface->sub.synchronous = FALSE; + if (!surface->sub.synchronous) + return; - if (was_effectively_synchronized && - !is_surface_effectively_synchronized (surface)) + is_parent_effectively_synchronized = + is_surface_effectively_synchronized (surface->sub.parent); + + if (!is_parent_effectively_synchronized) meta_wayland_surface_apply_cached_state (surface); + + surface->sub.synchronous = FALSE; } static const struct wl_subsurface_interface meta_wayland_wl_subsurface_interface = {