From b188e912c3d18b85a39aba603e593ad7c4778325 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 19 Nov 2013 14:03:35 +0200 Subject: [PATCH] compositor: fix sub-surface view stacking order If you opened a window with sub-surfaces, and then raised another window on top of that, the underlaying window's main surface was stacked properly, but the sub-surfaces remained on top of the raised window. IOW, the raised window was in between the other window and its sub-surfaces. This got broken in a7af70436b7dccfacd736626d6719b3e751fd985, "Split the geometry information from weston_surface out into weston_view". Fix the issues: In view_list_add_subsurface_view(), the views need to be added to the end of the list, not to the head. This alone fixes the above problem, but causes the sub-surface views to be stacked irrespective of their surface stacking order. The stacking order in this test case is fixed by the changes to view_list_add(), but for sub-sub-surfaces a similar change is needed in view_list_add_subsurface_view() too. In view_list_add(), build the view list in the sub-surface stacking order, instead of pulling the parent surface always on top. Also handle the case, when the subsurface_list is completely empty: the parent surface's view must still be added. Reported-by: Julien Isorce Signed-off-by: Pekka Paalanen Cc: Jason Ekstrand --- src/compositor.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/compositor.c b/src/compositor.c index cca81708..c14ec1ff 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -1612,11 +1612,18 @@ view_list_add_subsurface_view(struct weston_compositor *compositor, } weston_view_update_transform(view); - wl_list_insert(compositor->view_list.next, &view->link); - wl_list_for_each(child, &sub->surface->subsurface_list, parent_link) - if (child->surface != sub->surface) + if (wl_list_empty(&sub->surface->subsurface_list)) { + wl_list_insert(compositor->view_list.prev, &view->link); + return; + } + + wl_list_for_each(child, &sub->surface->subsurface_list, parent_link) { + if (child->surface == sub->surface) + wl_list_insert(compositor->view_list.prev, &view->link); + else view_list_add_subsurface_view(compositor, child, view); + } } static void @@ -1626,11 +1633,18 @@ view_list_add(struct weston_compositor *compositor, struct weston_subsurface *sub; weston_view_update_transform(view); - wl_list_insert(compositor->view_list.prev, &view->link); - wl_list_for_each(sub, &view->surface->subsurface_list, parent_link) - if (sub->surface != view->surface) + if (wl_list_empty(&view->surface->subsurface_list)) { + wl_list_insert(compositor->view_list.prev, &view->link); + return; + } + + wl_list_for_each(sub, &view->surface->subsurface_list, parent_link) { + if (sub->surface == view->surface) + wl_list_insert(compositor->view_list.prev, &view->link); + else view_list_add_subsurface_view(compositor, sub, view); + } } static void