surface: Check parents in weston_surface_is_mapped()

A subsurface is not considered to be fully 'mapped' unless its ancestors
are also mapped.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2023-07-11 16:46:58 +01:00 committed by Marius Vlad
parent 2faf491f61
commit cae789774a

View file

@ -2136,7 +2136,22 @@ weston_view_find_paint_node(struct weston_view *view,
WL_EXPORT bool
weston_surface_is_mapped(struct weston_surface *surface)
{
return surface->is_mapped;
struct weston_subsurface *sub = weston_surface_to_subsurface(surface);
/* This surface isn't mapped. */
if (!surface->is_mapped)
return false;
/* This surface is mapped, and has no parents to refer to. */
if (!sub || sub->parent == surface)
return true;
/* This subsurface's parent has since vanished. */
if (!sub->parent)
return false;
/* Check recursively up its parent tree. */
return weston_surface_is_mapped(sub->parent);
}
/** Check if the weston_surface is emitting an mapping commit