aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
authorcrondog <crondog@gmail.com>2015-12-30 18:34:58 +1100
committercrondog <crondog@gmail.com>2015-12-31 11:14:06 +1100
commit397b58e88fc09f63440170401d92b1cfea91e88f (patch)
tree453a09d600b7989ef2f03c48f5383091797d9422 /sway/commands.c
parentb5a21a08c7f216399af48d66ce2a4223cb4855c0 (diff)
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/commands.c')
-rw-r--r--sway/commands.c18
1 files changed, 18 insertions, 0 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 },