aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/split.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/split.c')
-rw-r--r--sway/commands/split.c23
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);