From 8b0073b1954b54792f74b9e024c51548143906ea Mon Sep 17 00:00:00 2001 From: wil Date: Wed, 21 Dec 2016 16:55:02 +0100 Subject: [PATCH] Added "layout incnmaster|incncol" commands --- sway/commands/layout.c | 30 ++++++++++++++++++++++++++++++ sway/sway.5.txt | 20 ++++++++++++++------ 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/sway/commands/layout.c b/sway/commands/layout.c index e6fa7ef1..5e2e8efd 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c @@ -74,6 +74,36 @@ struct cmd_results *cmd_layout(int argc, char **argv) { parent = new_container(parent, L_AUTO_BOTTOM); } swayc_change_layout(parent, L_AUTO_BOTTOM); + } else if (strcasecmp(argv[0], "incnmaster") == 0) { + if ((error = checkarg(argc, "layout incnmaster", + EXPECTED_EQUAL_TO, 2))) { + return error; + } + int inc = (int) strtol(argv[1], NULL, 10); + swayc_t *container = get_focused_view(swayc_active_workspace()); + if (container && inc && + is_auto_layout(container->parent->layout) && + ((int)container->parent->nb_master + inc >= 0)) { + for (int i = container->parent->nb_master; + i >= 0 && i < container->parent->children->length && + i != (int) container->parent->nb_master + inc;) { + ((swayc_t *) container->parent->children->items[i])->height = -1; + ((swayc_t *) container->parent->children->items[i])->width = -1; + i += inc > 0 ? 1 : -1; + } + container->parent->nb_master += inc; + } + } else if ((strcasecmp(argv[0], "incncol") == 0) && argc ==2) { + if ((error = checkarg(argc, "layout incncol", + EXPECTED_EQUAL_TO, 2))) { + return error; + } + int inc = (int) strtol(argv[1], NULL, 10); + swayc_t *container = get_focused_view(swayc_active_workspace()); + if (container && inc && is_auto_layout(container->parent->layout) && + ((int)container->parent->nb_slave_groups + inc >= 1)) { + container->parent->nb_slave_groups += inc; + } } } diff --git a/sway/sway.5.txt b/sway/sway.5.txt index 1f25ce14..2fa5f32e 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt @@ -39,7 +39,7 @@ The following commands may only be used in the configuration file. **set** :: Sets variable $name to _value_. You can use the new variable in the arguments of future commands. - + **orientation** :: Sets the default container layout for tiled containers. @@ -62,11 +62,14 @@ They are expected to be used with **bindsym** or at runtime through **swaymsg**( Make focused view floating, non-floating, or the opposite of what it is now. **focus** :: - Direction may be one of _up_, _down_, _left_, _right_, _parent_, or _child_. - The directional focus commands will move the focus in that direction. The parent - focus command will change the focus to the parent of the currently focused - container, which is useful, for example, to open a sibling of the parent - container, or to move the entire container around. + Direction may be one of _up_, _down_, _left_, _right_, _next_, _prev_, + _parent_, or _child_. The directional focus commands will move the focus + in that direction. The auto_next and auto_prev will focus the next, + respectively previous, element in the current container if it is using + one of the _auto_ layouts. The parent focus command will change the + focus to the parent of the currently focused container, which is useful, + for example, to open a sibling of the parent container, or to move the + entire container around. **focus** output :: Direction may be one of _up_, _down_, _left_, _right_. The directional focus @@ -84,6 +87,11 @@ They are expected to be used with **bindsym** or at runtime through **swaymsg**( _splitv_, _toggle split_, _stacking_, _tabbed_, _auto_left_, _auto_right_, _auto_top, _auto_bottom_. +**layout** :: + Modify the number of master elements, respectively slave columns, in the + focused container. can be a positive or negative integer. These commands + only have an effect if the focused container uses one of the "auto" layouts. + **move** :: Moves the focused container _left_, _right_, _up_, or _down_.