surface: Unmap subsurface views when parent is unmapped

Quoth the spec:
      A sub-surface becomes mapped, when a non-NULL wl_buffer is applied
      and the parent surface is mapped. The order of which one happens
      first is irrelevant. A sub-surface is hidden if the parent becomes
      hidden, or if a NULL wl_buffer is applied. These rules apply
      recursively through the tree of surfaces.

We currently apply this rule through reconstructing the view_list at
repaint time, materialising new views and garbage-collecting unwanted
views as appropriate. Since this can be a costly operation, it's best if
we move this closer to the source.

This makes the core recursively unmap any child views when the parent is
unmapped. Future commits will do the same for mapping new views.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2023-06-22 15:56:25 +01:00
parent 3af596a8bc
commit 3d9aecc846

View File

@ -2087,10 +2087,18 @@ WL_EXPORT void
weston_view_unmap(struct weston_view *view)
{
struct weston_seat *seat;
struct weston_view *child;
if (!weston_view_is_mapped(view))
return;
/* Recursively unmap any child views, e.g. subsurfaces */
wl_list_for_each(child, &view->geometry.child_list,
geometry.parent_link) {
if (child->parent_view == view)
weston_view_unmap(child);
}
weston_view_damage_below(view);
weston_view_set_output(view, NULL);
view->plane = NULL;