mirror of
https://github.com/labwc/labwc.git
synced 2025-11-05 13:29:58 -05:00
view: implement separate horizontal/vertical maximize
This is a useful (if lesser-known) feature of at least a few popular X11 window managers, for example Openbox and XFWM4. Typically right-click on the maximize button toggles horizontal maximize, while middle-click toggles vertical maximize. Support in labwc uses the same configuration syntax as Openbox, where the Maximize/ToggleMaximize actions have an optional "direction" argument: horizontal, vertical, or both (default). The default mouse bindings match the XFWM4 defaults (not sure what Openbox has by default). Most of the external protocols still assume "maximized" is a Boolean, which is no longer true internally. For the sake of the outside world, a view is only "maximized" if maximized in both directions. Internally, I've taken the following approach: - SSD code decorates the view as "maximized" (i.e. hiding borders) only if maximized in both directions. - Layout code (interactive move/resize, tiling, etc.) generally treats the view as "maximized" (with the restrictions that entails) if maximized in either direction. For example, moving a vertically- maximized view first restores the natural geometry (this differs from Openbox, which instead allows the view to move only horizontally.) v2: use enum view_axis for view->maximized v3: - update docs - allow resizing if partly maximized - add TODOs & corrections noted by Consolatis
This commit is contained in:
parent
7b644b3b94
commit
0430f6f818
15 changed files with 193 additions and 78 deletions
|
|
@ -35,7 +35,7 @@ ssd_thickness(struct view *view)
|
|||
|
||||
struct theme *theme = view->server->theme;
|
||||
|
||||
if (view->maximized) {
|
||||
if (view->maximized == VIEW_AXIS_BOTH) {
|
||||
struct border thickness = { 0 };
|
||||
if (!view->ssd_titlebar_hidden) {
|
||||
thickness.top += theme->title_height;
|
||||
|
|
@ -226,7 +226,8 @@ ssd_update_geometry(struct ssd *ssd)
|
|||
ssd_extents_update(ssd);
|
||||
ssd->state.geometry = current;
|
||||
}
|
||||
if (ssd->state.squared_corners != ssd->view->maximized) {
|
||||
bool maximized = (ssd->view->maximized == VIEW_AXIS_BOTH);
|
||||
if (ssd->state.squared_corners != maximized) {
|
||||
ssd_border_update(ssd);
|
||||
ssd_titlebar_update(ssd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ ssd_border_create(struct ssd *ssd)
|
|||
-(ssd->titlebar.height + theme->border_width), color);
|
||||
} FOR_EACH_END
|
||||
|
||||
if (view->maximized) {
|
||||
if (view->maximized == VIEW_AXIS_BOTH) {
|
||||
wlr_scene_node_set_enabled(&ssd->border.tree->node, false);
|
||||
}
|
||||
}
|
||||
|
|
@ -65,13 +65,14 @@ ssd_border_update(struct ssd *ssd)
|
|||
assert(ssd->border.tree);
|
||||
|
||||
struct view *view = ssd->view;
|
||||
if (view->maximized && ssd->border.tree->node.enabled) {
|
||||
if (view->maximized == VIEW_AXIS_BOTH
|
||||
&& ssd->border.tree->node.enabled) {
|
||||
/* Disable borders on maximize */
|
||||
wlr_scene_node_set_enabled(&ssd->border.tree->node, false);
|
||||
ssd->margin = ssd_thickness(ssd->view);
|
||||
}
|
||||
|
||||
if (view->maximized) {
|
||||
if (view->maximized == VIEW_AXIS_BOTH) {
|
||||
return;
|
||||
} else if (!ssd->border.tree->node.enabled) {
|
||||
/* And re-enabled them when unmaximized */
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ ssd_extents_create(struct ssd *ssd)
|
|||
|
||||
ssd->extents.tree = wlr_scene_tree_create(ssd->tree);
|
||||
struct wlr_scene_tree *parent = ssd->extents.tree;
|
||||
if (view->maximized || view->fullscreen) {
|
||||
if (view->fullscreen || view->maximized == VIEW_AXIS_BOTH) {
|
||||
wlr_scene_node_set_enabled(&parent->node, false);
|
||||
}
|
||||
wl_list_init(&ssd->extents.parts);
|
||||
|
|
@ -89,7 +89,7 @@ void
|
|||
ssd_extents_update(struct ssd *ssd)
|
||||
{
|
||||
struct view *view = ssd->view;
|
||||
if (view->maximized || view->fullscreen) {
|
||||
if (view->fullscreen || view->maximized == VIEW_AXIS_BOTH) {
|
||||
wlr_scene_node_set_enabled(&ssd->extents.tree->node, false);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ ssd_titlebar_create(struct ssd *ssd)
|
|||
|
||||
ssd_update_title(ssd);
|
||||
|
||||
if (view->maximized) {
|
||||
set_squared_corners(ssd, view->maximized);
|
||||
if (view->maximized == VIEW_AXIS_BOTH) {
|
||||
set_squared_corners(ssd, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,8 +133,9 @@ ssd_titlebar_update(struct ssd *ssd)
|
|||
int width = view->current.width;
|
||||
struct theme *theme = view->server->theme;
|
||||
|
||||
if (view->maximized != ssd->state.squared_corners) {
|
||||
set_squared_corners(ssd, view->maximized);
|
||||
bool maximized = (view->maximized == VIEW_AXIS_BOTH);
|
||||
if (ssd->state.squared_corners != maximized) {
|
||||
set_squared_corners(ssd, maximized);
|
||||
}
|
||||
|
||||
if (width == ssd->state.geometry.width) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue