diff options
author | crondog <crondog@gmail.com> | 2015-12-30 18:34:58 +1100 |
---|---|---|
committer | crondog <crondog@gmail.com> | 2015-12-31 11:14:06 +1100 |
commit | 397b58e88fc09f63440170401d92b1cfea91e88f (patch) | |
tree | 453a09d600b7989ef2f03c48f5383091797d9422 /sway | |
parent | Merge pull request #419 from crondog/fullscreen (diff) | |
download | sway-397b58e88fc09f63440170401d92b1cfea91e88f.tar.gz sway-397b58e88fc09f63440170401d92b1cfea91e88f.tar.zst sway-397b58e88fc09f63440170401d92b1cfea91e88f.zip |
split toggle
Not sure if you will accept this, but i find it useful (I use it when
opening new terminal windows on a workspace
v2: add short hand command and docs
Diffstat (limited to 'sway')
-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; | |||
61 | static sway_cmd cmd_set; | 61 | static sway_cmd cmd_set; |
62 | static sway_cmd cmd_split; | 62 | static sway_cmd cmd_split; |
63 | static sway_cmd cmd_splith; | 63 | static sway_cmd cmd_splith; |
64 | static sway_cmd cmd_splitt; | ||
64 | static sway_cmd cmd_splitv; | 65 | static sway_cmd cmd_splitv; |
65 | static sway_cmd cmd_sticky; | 66 | static sway_cmd cmd_sticky; |
66 | static sway_cmd cmd_workspace; | 67 | static sway_cmd cmd_workspace; |
@@ -1340,6 +1341,13 @@ static struct cmd_results *cmd_split(int argc, char **argv) { | |||
1340 | _do_split(argc - 1, argv + 1, L_VERT); | 1341 | _do_split(argc - 1, argv + 1, L_VERT); |
1341 | } else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) { | 1342 | } else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) { |
1342 | _do_split(argc - 1, argv + 1, L_HORIZ); | 1343 | _do_split(argc - 1, argv + 1, L_HORIZ); |
1344 | } else if (strcasecmp(argv[0], "t") == 0 || strcasecmp(argv[0], "toggle") == 0) { | ||
1345 | swayc_t *focused = get_focused_container(&root_container); | ||
1346 | if (focused->parent->layout == L_VERT) { | ||
1347 | _do_split(argc - 1, argv + 1, L_HORIZ); | ||
1348 | } else { | ||
1349 | _do_split(argc - 1, argv + 1, L_VERT); | ||
1350 | } | ||
1343 | } else { | 1351 | } else { |
1344 | error = cmd_results_new(CMD_FAILURE, "split", | 1352 | error = cmd_results_new(CMD_FAILURE, "split", |
1345 | "Invalid split command (expected either horiziontal or vertical)."); | 1353 | "Invalid split command (expected either horiziontal or vertical)."); |
@@ -1356,6 +1364,15 @@ static struct cmd_results *cmd_splith(int argc, char **argv) { | |||
1356 | return _do_split(argc, argv, L_HORIZ); | 1364 | return _do_split(argc, argv, L_HORIZ); |
1357 | } | 1365 | } |
1358 | 1366 | ||
1367 | static struct cmd_results *cmd_splitt(int argc, char **argv) { | ||
1368 | swayc_t *focused = get_focused_container(&root_container); | ||
1369 | if (focused->parent->layout == L_VERT) { | ||
1370 | return _do_split(argc, argv, L_HORIZ); | ||
1371 | } else { | ||
1372 | return _do_split(argc, argv, L_VERT); | ||
1373 | } | ||
1374 | } | ||
1375 | |||
1359 | static struct cmd_results *cmd_sticky(int argc, char **argv) { | 1376 | static struct cmd_results *cmd_sticky(int argc, char **argv) { |
1360 | struct cmd_results *error = NULL; | 1377 | struct cmd_results *error = NULL; |
1361 | if (config->reading) return cmd_results_new(CMD_FAILURE, "sticky", "Can't be used in config file."); | 1378 | 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[] = { | |||
1567 | { "set", cmd_set }, | 1584 | { "set", cmd_set }, |
1568 | { "split", cmd_split }, | 1585 | { "split", cmd_split }, |
1569 | { "splith", cmd_splith }, | 1586 | { "splith", cmd_splith }, |
1587 | { "splitt", cmd_splitt }, | ||
1570 | { "splitv", cmd_splitv }, | 1588 | { "splitv", cmd_splitv }, |
1571 | { "sticky", cmd_sticky }, | 1589 | { "sticky", cmd_sticky }, |
1572 | { "workspace", cmd_workspace }, | 1590 | { "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 | |||
163 | Creates a substitution for _value_ that can be used with $_name_ in other | 163 | Creates a substitution for _value_ that can be used with $_name_ in other |
164 | commands. | 164 | commands. |
165 | 165 | ||
166 | **split** <vertical|v|horizontal|h>:: | 166 | **split** <vertical|v|horizontal|h|toggle|t>:: |
167 | Splits the current container, vertically or horizontally. | 167 | Splits the current container, vertically or horizontally. If toggled then the |
168 | current container is split opposite to the parent container. | ||
168 | 169 | ||
169 | **splith**:: | 170 | **splith**:: |
170 | Equivalent to **split horizontal**. | 171 | Equivalent to **split horizontal**. |
@@ -172,6 +173,9 @@ Commands | |||
172 | **splitv**:: | 173 | **splitv**:: |
173 | Equivalent to **split vertical**. | 174 | Equivalent to **split vertical**. |
174 | 175 | ||
176 | **splitt**:: | ||
177 | Equivalent to **split toggle**. | ||
178 | |||
175 | **sticky** <enable|disable|toggle>:: | 179 | **sticky** <enable|disable|toggle>:: |
176 | If enabled and the windows is floating it will always be present on the active | 180 | If enabled and the windows is floating it will always be present on the active |
177 | workspace on that output. | 181 | workspace on that output. |