diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-09-05 09:33:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-05 09:33:27 -0400 |
commit | 610eb946171f782165a20614b2d3318b89273990 (patch) | |
tree | 05eec1df1ef48e05b23d273d31143ad32e7632d2 /sway/commands/split.c | |
parent | aa2bf98e0442f9bf41a852c2fafee5b0897010a2 (diff) | |
parent | dbf4aa3e33bdee53876c6893b15ac3f224818e7c (diff) |
Merge pull request #2540 from RyanDwyer/typesafety
Implement type safe arguments and demote sway_container
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 @@ #include "sway/tree/arrange.h" #include "sway/tree/container.h" #include "sway/tree/view.h" +#include "sway/tree/workspace.h" #include "sway/input/input-manager.h" #include "sway/input/seat.h" #include "log.h" static struct cmd_results *do_split(int layout) { - struct sway_container *con = config->handler_context.current_container; - struct sway_container *parent = container_split(con, layout); - container_create_notify(parent); - arrange_windows(parent->parent); + struct sway_container *con = config->handler_context.container; + struct sway_workspace *ws = config->handler_context.workspace; + if (con) { + container_split(con, layout); + } else { + workspace_split(ws, layout); + } + + arrange_workspace(ws); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } @@ -29,10 +35,9 @@ struct cmd_results *cmd_split(int argc, char **argv) { return do_split(L_HORIZ); } else if (strcasecmp(argv[0], "t") == 0 || strcasecmp(argv[0], "toggle") == 0) { - struct sway_container *focused = - config->handler_context.current_container; + struct sway_container *focused = config->handler_context.container; - if (focused->parent->layout == L_VERT) { + if (focused && container_parent_layout(focused) == L_VERT) { return do_split(L_HORIZ); } else { return do_split(L_VERT); @@ -66,9 +71,9 @@ struct cmd_results *cmd_splitt(int argc, char **argv) { return error; } - struct sway_container *con = config->handler_context.current_container; + struct sway_container *con = config->handler_context.container; - if (con->parent->layout == L_VERT) { + if (con && container_parent_layout(con) == L_VERT) { return do_split(L_HORIZ); } else { return do_split(L_VERT); |