[mutter] wayland/subsurface: Ensure cached state recursivly gets applied on set_desync()



commit 03434e566a4aedd865cb642154abbe1e0cfe9a02
Author: Robert Mader <robert mader collabora com>
Date:   Mon Jan 10 20:11:47 2022 +0100

    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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2232>

 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 7e996f4d34..1e9b655289 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;
+
+  is_parent_effectively_synchronized =
+    is_surface_effectively_synchronized (surface->sub.parent);
 
-  if (was_effectively_synchronized &&
-      !is_surface_effectively_synchronized (surface))
+  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 = {


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