mirror of
https://github.com/labwc/labwc.git
synced 2026-02-15 22:05:25 -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
57
src/view.c
57
src/view.c
|
|
@ -238,8 +238,8 @@ view_adjust_size(struct view *view, int *w, int *h)
|
|||
*h = MAX(*h, LAB_MIN_VIEW_HEIGHT);
|
||||
}
|
||||
|
||||
void
|
||||
view_minimize(struct view *view, bool minimized)
|
||||
static void
|
||||
_minimize(struct view *view, bool minimized)
|
||||
{
|
||||
assert(view);
|
||||
if (view->minimized == minimized) {
|
||||
|
|
@ -272,6 +272,40 @@ view_minimize(struct view *view, bool minimized)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
minimize_sub_views(struct view *view, bool minimized)
|
||||
{
|
||||
struct view **child;
|
||||
struct wl_array children;
|
||||
|
||||
wl_array_init(&children);
|
||||
view_append_children(view, &children);
|
||||
wl_array_for_each(child, &children) {
|
||||
_minimize(*child, minimized);
|
||||
minimize_sub_views(*child, minimized);
|
||||
}
|
||||
wl_array_release(&children);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
void
|
||||
view_minimize(struct view *view, bool minimized)
|
||||
{
|
||||
/*
|
||||
* Minimize the root window first because some xwayland clients send a
|
||||
* request-unmap to sub-windows at this point (for example gimp and its
|
||||
* 'open file' dialog), so it saves trying to unmap them twice
|
||||
*/
|
||||
struct view *root = view_get_root(view);
|
||||
_minimize(root, minimized);
|
||||
minimize_sub_views(root, minimized);
|
||||
}
|
||||
|
||||
static bool
|
||||
view_compute_centered_position(struct view *view, const struct wlr_box *ref,
|
||||
int w, int h, int *x, int *y)
|
||||
|
|
@ -1042,6 +1076,25 @@ view_move_to_back(struct view *view)
|
|||
}
|
||||
}
|
||||
|
||||
struct view *
|
||||
view_get_root(struct view *view)
|
||||
{
|
||||
assert(view);
|
||||
if (view->impl->get_root) {
|
||||
return view->impl->get_root(view);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
void
|
||||
view_append_children(struct view *view, struct wl_array *children)
|
||||
{
|
||||
assert(view);
|
||||
if (view->impl->append_children) {
|
||||
view->impl->append_children(view, children);
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
view_get_string_prop(struct view *view, const char *prop)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue