diff options
-rw-r--r-- | sway/commands.c | 18 | ||||
-rw-r--r-- | sway/sway.5.txt | 8 |
2 files changed, 24 insertions, 2 deletions
diff --git a/sway/commands.c b/sway/commands.c index 4d5018a0..6c24395f 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -61,6 +61,7 @@ static sway_cmd cmd_scratchpad; static sway_cmd cmd_set; static sway_cmd cmd_split; static sway_cmd cmd_splith; +static sway_cmd cmd_splitt; static sway_cmd cmd_splitv; static sway_cmd cmd_sticky; static sway_cmd cmd_workspace; @@ -1340,6 +1341,13 @@ static struct cmd_results *cmd_split(int argc, char **argv) { _do_split(argc - 1, argv + 1, L_VERT); } else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) { _do_split(argc - 1, argv + 1, L_HORIZ); + } else if (strcasecmp(argv[0], "t") == 0 || strcasecmp(argv[0], "toggle") == 0) { + swayc_t *focused = get_focused_container(&root_container); + if (focused->parent->layout == L_VERT) { + _do_split(argc - 1, argv + 1, L_HORIZ); + } else { + _do_split(argc - 1, argv + 1, L_VERT); + } } else { error = cmd_results_new(CMD_FAILURE, "split", "Invalid split command (expected either horiziontal or vertical)."); @@ -1356,6 +1364,15 @@ static struct cmd_results *cmd_splith(int argc, char **argv) { return _do_split(argc, argv, L_HORIZ); } +static struct cmd_results *cmd_splitt(int argc, char **argv) { + swayc_t *focused = get_focused_container(&root_container); + if (focused->parent->layout == L_VERT) { + return _do_split(argc, argv, L_HORIZ); + } else { + return _do_split(argc, argv, L_VERT); + } +} + static struct cmd_results *cmd_sticky(int argc, char **argv) { struct cmd_results *error = NULL; if (config->reading) return cmd_results_new(CMD_FAILURE, "sticky", "Can't be used in config file."); @@ -1567,6 +1584,7 @@ static struct cmd_handler handlers[] = { { "set", cmd_set }, { "split", cmd_split }, { "splith", cmd_splith }, + { "splitt", cmd_splitt }, { "splitv", cmd_splitv }, { "sticky", cmd_sticky }, { "workspace", cmd_workspace }, diff --git a/sway/sway.5.txt b/sway/sway.5.txt index c3736d01..9777491e 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt @@ -163,8 +163,9 @@ Commands Creates a substitution for _value_ that can be used with $_name_ in other commands. -**split** <vertical|v|horizontal|h>:: - Splits the current container, vertically or horizontally. +**split** <vertical|v|horizontal|h|toggle|t>:: + Splits the current container, vertically or horizontally. If toggled then the + current container is split opposite to the parent container. **splith**:: Equivalent to **split horizontal**. @@ -172,6 +173,9 @@ Commands **splitv**:: Equivalent to **split vertical**. +**splitt**:: + Equivalent to **split toggle**. + **sticky** <enable|disable|toggle>:: If enabled and the windows is floating it will always be present on the active workspace on that output. |