diff options
Diffstat (limited to 'sway/commands/split.c')
-rw-r--r-- | sway/commands/split.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/sway/commands/split.c b/sway/commands/split.c index a8eddf54..9a53f3d3 100644 --- a/sway/commands/split.c +++ b/sway/commands/split.c | |||
@@ -4,15 +4,21 @@ | |||
4 | #include "sway/tree/arrange.h" | 4 | #include "sway/tree/arrange.h" |
5 | #include "sway/tree/container.h" | 5 | #include "sway/tree/container.h" |
6 | #include "sway/tree/view.h" | 6 | #include "sway/tree/view.h" |
7 | #include "sway/tree/workspace.h" | ||
7 | #include "sway/input/input-manager.h" | 8 | #include "sway/input/input-manager.h" |
8 | #include "sway/input/seat.h" | 9 | #include "sway/input/seat.h" |
9 | #include "log.h" | 10 | #include "log.h" |
10 | 11 | ||
11 | static struct cmd_results *do_split(int layout) { | 12 | static struct cmd_results *do_split(int layout) { |
12 | struct sway_container *con = config->handler_context.current_container; | 13 | struct sway_container *con = config->handler_context.container; |
13 | struct sway_container *parent = container_split(con, layout); | 14 | struct sway_workspace *ws = config->handler_context.workspace; |
14 | container_create_notify(parent); | 15 | if (con) { |
15 | arrange_windows(parent->parent); | 16 | container_split(con, layout); |
17 | } else { | ||
18 | workspace_split(ws, layout); | ||
19 | } | ||
20 | |||
21 | arrange_workspace(ws); | ||
16 | 22 | ||
17 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 23 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
18 | } | 24 | } |
@@ -29,10 +35,9 @@ struct cmd_results *cmd_split(int argc, char **argv) { | |||
29 | return do_split(L_HORIZ); | 35 | return do_split(L_HORIZ); |
30 | } else if (strcasecmp(argv[0], "t") == 0 || | 36 | } else if (strcasecmp(argv[0], "t") == 0 || |
31 | strcasecmp(argv[0], "toggle") == 0) { | 37 | strcasecmp(argv[0], "toggle") == 0) { |
32 | struct sway_container *focused = | 38 | struct sway_container *focused = config->handler_context.container; |
33 | config->handler_context.current_container; | ||
34 | 39 | ||
35 | if (focused->parent->layout == L_VERT) { | 40 | if (focused && container_parent_layout(focused) == L_VERT) { |
36 | return do_split(L_HORIZ); | 41 | return do_split(L_HORIZ); |
37 | } else { | 42 | } else { |
38 | return do_split(L_VERT); | 43 | return do_split(L_VERT); |
@@ -66,9 +71,9 @@ struct cmd_results *cmd_splitt(int argc, char **argv) { | |||
66 | return error; | 71 | return error; |
67 | } | 72 | } |
68 | 73 | ||
69 | struct sway_container *con = config->handler_context.current_container; | 74 | struct sway_container *con = config->handler_context.container; |
70 | 75 | ||
71 | if (con->parent->layout == L_VERT) { | 76 | if (con && container_parent_layout(con) == L_VERT) { |
72 | return do_split(L_HORIZ); | 77 | return do_split(L_HORIZ); |
73 | } else { | 78 | } else { |
74 | return do_split(L_VERT); | 79 | return do_split(L_VERT); |