mirror of
https://github.com/labwc/labwc.git
synced 2026-02-24 01:40:15 -05:00
view: minimize parents/children together
Minimize the whole view-hierarchy from top to bottom regardless of which one in the hierarchy requested the minimize. For example, if an 'About' or 'Open File' dialog is minimized, its toplevel is minimized also, and vice versa. For reference: - This is consistent with in openbox, where child views (dialogs) can be minimized, but when doing so the parent is also minimized. - In mutter these types of dialogs cannot be minimized (via client-menu or otherwise). - In both openbox and mutter, when a toplevel window is minimized any open children are also minimized.
This commit is contained in:
parent
d961dbf9b0
commit
e991eae103
4 changed files with 134 additions and 8 deletions
37
src/xdg.c
37
src/xdg.c
|
|
@ -335,6 +335,10 @@ enum z_direction {
|
|||
LAB_TO_BACK,
|
||||
};
|
||||
|
||||
/*
|
||||
* TODO: Combine append_children() and move_sub_views() as much as possible.
|
||||
* https://github.com/labwc/labwc/pull/998#discussion_r1284085575
|
||||
*/
|
||||
static void
|
||||
move_sub_views(struct view *parent, enum z_direction z_direction)
|
||||
{
|
||||
|
|
@ -371,7 +375,7 @@ move_sub_views(struct view *parent, enum z_direction z_direction)
|
|||
|
||||
/* Return the most senior parent (=root) view */
|
||||
static struct view *
|
||||
root_view_of_view(struct view *view)
|
||||
xdg_toplevel_view_get_root(struct view *view)
|
||||
{
|
||||
struct wlr_xdg_toplevel *root = top_parent_of(view);
|
||||
struct wlr_xdg_surface *surface = (struct wlr_xdg_surface *)root->base;
|
||||
|
|
@ -387,7 +391,7 @@ root_view_of_view(struct view *view)
|
|||
static void
|
||||
xdg_toplevel_view_move_to_front(struct view *view)
|
||||
{
|
||||
struct view *root = root_view_of_view(view);
|
||||
struct view *root = xdg_toplevel_view_get_root(view);
|
||||
view_impl_move_to_front(root);
|
||||
move_sub_views(root, LAB_TO_FRONT);
|
||||
}
|
||||
|
|
@ -395,11 +399,36 @@ xdg_toplevel_view_move_to_front(struct view *view)
|
|||
static void
|
||||
xdg_toplevel_view_move_to_back(struct view *view)
|
||||
{
|
||||
struct view *root = root_view_of_view(view);
|
||||
struct view *root = xdg_toplevel_view_get_root(view);
|
||||
view_impl_move_to_back(root);
|
||||
move_sub_views(root, LAB_TO_BACK);
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_toplevel_view_append_children(struct view *self, struct wl_array *children)
|
||||
{
|
||||
struct wlr_xdg_toplevel *toplevel = xdg_toplevel_from_view(self);
|
||||
struct view *view;
|
||||
|
||||
wl_list_for_each_reverse(view, &self->server->views, link)
|
||||
{
|
||||
if (view == self) {
|
||||
continue;
|
||||
}
|
||||
if (view->type != LAB_XDG_SHELL_VIEW) {
|
||||
continue;
|
||||
}
|
||||
if (!view->mapped && !view->minimized) {
|
||||
continue;
|
||||
}
|
||||
if (top_parent_of(view) != toplevel) {
|
||||
continue;
|
||||
}
|
||||
struct view **child = wl_array_add(children, sizeof(*child));
|
||||
*child = view;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_toplevel_view_set_activated(struct view *view, bool activated)
|
||||
{
|
||||
|
|
@ -554,6 +583,8 @@ static const struct view_impl xdg_toplevel_view_impl = {
|
|||
.minimize = xdg_toplevel_view_minimize,
|
||||
.move_to_front = xdg_toplevel_view_move_to_front,
|
||||
.move_to_back = xdg_toplevel_view_move_to_back,
|
||||
.get_root = xdg_toplevel_view_get_root,
|
||||
.append_children = xdg_toplevel_view_append_children,
|
||||
};
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue