aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/split.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-25 17:10:58 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-01 23:14:58 +1000
commit5d69a56209dc6138272de6cdbd8f066d37199727 (patch)
treee81473b2d1e47bd0a07e858c278e7182c6aec7e6 /sway/commands/split.c
parentFix issues with sticky containers and workspaces (diff)
downloadsway-5d69a56209dc6138272de6cdbd8f066d37199727.tar.gz
sway-5d69a56209dc6138272de6cdbd8f066d37199727.tar.zst
sway-5d69a56209dc6138272de6cdbd8f066d37199727.zip
Prevent splitting a floating view
Diffstat (limited to 'sway/commands/split.c')
-rw-r--r--sway/commands/split.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sway/commands/split.c b/sway/commands/split.c
index 0a61ac8d..57e42a5a 100644
--- a/sway/commands/split.c
+++ b/sway/commands/split.c
@@ -10,6 +10,10 @@
10 10
11static struct cmd_results *do_split(int layout) { 11static struct cmd_results *do_split(int layout) {
12 struct sway_container *con = config->handler_context.current_container; 12 struct sway_container *con = config->handler_context.current_container;
13 if (container_is_floating(con)) {
14 return cmd_results_new(CMD_FAILURE, "split",
15 "Can't split a floating view");
16 }
13 struct sway_container *parent = container_split(con, layout); 17 struct sway_container *parent = container_split(con, layout);
14 container_create_notify(parent); 18 container_create_notify(parent);
15 arrange_children_of(parent); 19 arrange_children_of(parent);
@@ -23,24 +27,23 @@ struct cmd_results *cmd_split(int argc, char **argv) {
23 return error; 27 return error;
24 } 28 }
25 if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) { 29 if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) {
26 do_split(L_VERT); 30 return do_split(L_VERT);
27 } else if (strcasecmp(argv[0], "h") == 0 || 31 } else if (strcasecmp(argv[0], "h") == 0 ||
28 strcasecmp(argv[0], "horizontal") == 0) { 32 strcasecmp(argv[0], "horizontal") == 0) {
29 do_split(L_HORIZ); 33 return do_split(L_HORIZ);
30 } else if (strcasecmp(argv[0], "t") == 0 || 34 } else if (strcasecmp(argv[0], "t") == 0 ||
31 strcasecmp(argv[0], "toggle") == 0) { 35 strcasecmp(argv[0], "toggle") == 0) {
32 struct sway_container *focused = 36 struct sway_container *focused =
33 config->handler_context.current_container; 37 config->handler_context.current_container;
34 38
35 if (focused->parent->layout == L_VERT) { 39 if (focused->parent->layout == L_VERT) {
36 do_split(L_HORIZ); 40 return do_split(L_HORIZ);
37 } else { 41 } else {
38 do_split(L_VERT); 42 return do_split(L_VERT);
39 } 43 }
40 } else { 44 } else {
41 error = cmd_results_new(CMD_FAILURE, "split", 45 return cmd_results_new(CMD_FAILURE, "split",
42 "Invalid split command (expected either horizontal or vertical)."); 46 "Invalid split command (expected either horizontal or vertical).");
43 return error;
44 } 47 }
45 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 48 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
46} 49}