compositor: allow using nested parent as a subsurface sibling

The parent of a subsurface can be used as a sibling in the place_below
and place_above calls. However this did not work when the parent is
nested, so fix the sibling check and add a test to check this case.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Arnaud Vrac
2016-06-08 18:37:57 +02:00
committed by Daniel Stone
parent 11f8fcbefe
commit b8c16c995b
2 changed files with 54 additions and 18 deletions
+10 -18
View File
@@ -3521,17 +3521,16 @@ subsurface_set_position(struct wl_client *client,
}
static struct weston_subsurface *
subsurface_from_surface(struct weston_surface *surface)
subsurface_find_sibling(struct weston_subsurface *sub,
struct weston_surface *surface)
{
struct weston_subsurface *sub;
struct weston_surface *parent = sub->parent;
struct weston_subsurface *sibling;
sub = weston_surface_to_subsurface(surface);
if (sub)
return sub;
wl_list_for_each(sub, &surface->subsurface_list, parent_link)
if (sub->surface == surface)
return sub;
wl_list_for_each(sibling, &parent->subsurface_list, parent_link) {
if (sibling->surface == surface && sibling != sub)
return sibling;
}
return NULL;
}
@@ -3543,8 +3542,7 @@ subsurface_sibling_check(struct weston_subsurface *sub,
{
struct weston_subsurface *sibling;
sibling = subsurface_from_surface(surface);
sibling = subsurface_find_sibling(sub, surface);
if (!sibling) {
wl_resource_post_error(sub->resource,
WL_SUBSURFACE_ERROR_BAD_SURFACE,
@@ -3553,13 +3551,7 @@ subsurface_sibling_check(struct weston_subsurface *sub,
return NULL;
}
if (sibling->parent != sub->parent) {
wl_resource_post_error(sub->resource,
WL_SUBSURFACE_ERROR_BAD_SURFACE,
"%s: wl_surface@%d has a different parent",
request, wl_resource_get_id(surface->resource));
return NULL;
}
assert(sibling->parent == sub->parent);
return sibling;
}