view: make move_sub_views() use append_children method

...to share common code with minimize_sub_views()

Also, fix a bug in the move-to-back functions to move the window
hierarchy in the right order.

Helped-by: @Consolatis
This commit is contained in:
Johan Malm 2023-08-05 19:02:05 +01:00 committed by Consolatis
parent e991eae103
commit 2c14a5a406
4 changed files with 35 additions and 91 deletions

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/* view-impl-common.c: common code for shell view->impl functions */
#include <assert.h>
#include <stdio.h>
#include <strings.h>
#include "common/list.h"
@ -24,6 +25,29 @@ view_impl_move_to_back(struct view *view)
wlr_scene_node_lower_to_bottom(&view->scene_tree->node);
}
void
view_impl_move_sub_views(struct view *parent, enum z_direction z_direction)
{
assert(parent);
if (!parent->impl->append_children) {
return;
}
struct wl_array subviews;
wl_array_init(&subviews);
parent->impl->append_children(parent, &subviews);
struct view **view;
wl_array_for_each(view, &subviews) {
if (z_direction == LAB_TO_FRONT) {
view_impl_move_to_front(*view);
} else if (z_direction == LAB_TO_BACK) {
view_impl_move_to_back(*view);
}
}
wl_array_release(&subviews);
}
void
view_impl_map(struct view *view)
{