From 8f4ab53bd6c116fded360a683d9d1dc0559a2fdb Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Wed, 4 Oct 2023 22:45:13 +0200 Subject: [PATCH] window-actor/wayland: Ensure to use allocation for black background check The surface actors may not have a valid allocation when running the test. The preferred height, which `clutter_actor_get_size()` returns in that case, can be wrong in certain cases, making us not add the black background when it's actually needed. Query the allocation instead, even at the expense of additional relayouts. While on it, sneak it some small cleanups. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3024 Part-of: --- src/compositor/meta-window-actor-wayland.c | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/compositor/meta-window-actor-wayland.c b/src/compositor/meta-window-actor-wayland.c index 7522df05b..d6f125ebf 100644 --- a/src/compositor/meta-window-actor-wayland.c +++ b/src/compositor/meta-window-actor-wayland.c @@ -498,24 +498,23 @@ maybe_configure_black_background (MetaWindowActorWayland *self, clutter_actor_iter_init (&iter, CLUTTER_ACTOR (self->surface_container)); while (clutter_actor_iter_next (&iter, &child)) { - float child_width, child_height; + ClutterActorBox actor_box; - clutter_actor_get_size (child, &child_width, &child_height); + if (!clutter_actor_is_mapped (child)) + continue; - if (META_IS_SURFACE_ACTOR (child) && - meta_surface_actor_is_opaque (META_SURFACE_ACTOR (child)) && - G_APPROX_VALUE (clutter_actor_get_x (child), 0, + clutter_actor_get_allocation_box (child, &actor_box); + if (meta_surface_actor_is_opaque (META_SURFACE_ACTOR (child)) && + G_APPROX_VALUE (actor_box.x1, 0, CLUTTER_COORDINATE_EPSILON) && + G_APPROX_VALUE (actor_box.y1, 0, CLUTTER_COORDINATE_EPSILON) && + G_APPROX_VALUE (actor_box.x2, fullscreen_layout.width, CLUTTER_COORDINATE_EPSILON) && - G_APPROX_VALUE (clutter_actor_get_y (child), 0, - CLUTTER_COORDINATE_EPSILON) && - G_APPROX_VALUE (child_width, fullscreen_layout.width, - CLUTTER_COORDINATE_EPSILON) && - G_APPROX_VALUE (child_height, fullscreen_layout.height, + G_APPROX_VALUE (actor_box.y2, fullscreen_layout.height, CLUTTER_COORDINATE_EPSILON)) return FALSE; - max_width = MAX (max_width, child_width); - max_height = MAX (max_height, child_height); + max_width = MAX (max_width, actor_box.x2 - actor_box.x1); + max_height = MAX (max_height, actor_box.y2 - actor_box.y1); } *surfaces_width = max_width;