From 7706d83160267be61accb1b6f7bdc2f43299cae7 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 31 Mar 2018 00:44:17 -0400 Subject: basic split containers --- sway/commands/kill.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'sway/commands/kill.c') diff --git a/sway/commands/kill.c b/sway/commands/kill.c index f6774767..80120832 100644 --- a/sway/commands/kill.c +++ b/sway/commands/kill.c @@ -3,21 +3,30 @@ #include "sway/input/input-manager.h" #include "sway/input/seat.h" #include "sway/tree/view.h" +#include "sway/tree/container.h" #include "sway/commands.h" struct cmd_results *cmd_kill(int argc, char **argv) { - enum sway_container_type type = config->handler_context.current_container->type; - if (type != C_VIEW && type != C_CONTAINER) { + struct sway_container *con = + config->handler_context.current_container; + + switch (con->type) { + case C_ROOT: + case C_OUTPUT: + case C_WORKSPACE: return cmd_results_new(CMD_INVALID, NULL, "Can only kill views and containers with this command"); - } - - // TODO close arbitrary containers without a view - struct sway_view *view = - config->handler_context.current_container->sway_view; - - if (view) { - view_close(view); + break; + case C_CONTAINER: + con = container_destroy(con); + con = container_reap_empty(con); + arrange_windows(con, -1, -1); + break; + case C_VIEW: + view_close(con->sway_view); + break; + default: + break; } return cmd_results_new(CMD_SUCCESS, NULL, NULL); -- cgit v1.2.3 From e7ecb001d70c71f799547d15cd45c235412af402 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 31 Mar 2018 13:20:05 -0400 Subject: reap container parent on destroy --- sway/commands/kill.c | 1 - sway/tree/container.c | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'sway/commands/kill.c') diff --git a/sway/commands/kill.c b/sway/commands/kill.c index 80120832..e6036cb3 100644 --- a/sway/commands/kill.c +++ b/sway/commands/kill.c @@ -19,7 +19,6 @@ struct cmd_results *cmd_kill(int argc, char **argv) { break; case C_CONTAINER: con = container_destroy(con); - con = container_reap_empty(con); arrange_windows(con, -1, -1); break; case C_VIEW: diff --git a/sway/tree/container.c b/sway/tree/container.c index 7b88cccb..f972ac24 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -58,7 +58,7 @@ struct sway_container *container_create(enum sway_container_type type) { return c; } -struct sway_container *container_destroy(struct sway_container *cont) { +static struct sway_container *_container_destroy(struct sway_container *cont) { if (cont == NULL) { return NULL; } @@ -89,6 +89,11 @@ struct sway_container *container_destroy(struct sway_container *cont) { return parent; } +struct sway_container *container_destroy(struct sway_container *cont) { + cont = _container_destroy(cont); + return container_reap_empty(cont->parent); +} + struct sway_container *container_output_create( struct sway_output *sway_output) { struct wlr_box size; -- cgit v1.2.3 From b5d49cc4e86b5da5a3479c2d2a763be50184f75d Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 31 Mar 2018 21:05:58 -0400 Subject: remove default from kill switch --- sway/commands/kill.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sway/commands/kill.c') diff --git a/sway/commands/kill.c b/sway/commands/kill.c index e6036cb3..46d6e98e 100644 --- a/sway/commands/kill.c +++ b/sway/commands/kill.c @@ -14,6 +14,7 @@ struct cmd_results *cmd_kill(int argc, char **argv) { case C_ROOT: case C_OUTPUT: case C_WORKSPACE: + case C_TYPES: return cmd_results_new(CMD_INVALID, NULL, "Can only kill views and containers with this command"); break; @@ -24,8 +25,6 @@ struct cmd_results *cmd_kill(int argc, char **argv) { case C_VIEW: view_close(con->sway_view); break; - default: - break; } return cmd_results_new(CMD_SUCCESS, NULL, NULL); -- cgit v1.2.3