summaryrefslogtreecommitdiff
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorTony Crisci <[email protected]>2018-04-02 21:01:33 -0400
committerTony Crisci <[email protected]>2018-04-02 21:01:33 -0400
commit2c165e1288cbb60f5e677595e35f58a9c56c7010 (patch)
tree8dc7105631a62ce2635bb18cf26abea5d02e7837 /sway/tree/container.c
parent32ef182f474dbb40c4bedb69256ca6ec8bd31039 (diff)
fix more close segfaults
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 4db93ce8..8688edd6 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -112,10 +112,45 @@ static struct sway_container *_container_destroy(struct sway_container *cont) {
struct sway_container *container_destroy(struct sway_container *cont) {
struct sway_container *parent = _container_destroy(cont);
parent = container_reap_empty(parent);
- arrange_windows(&root_container, -1, -1);
return parent;
}
+static void container_close_func(struct sway_container *container, void *data) {
+ if (container->type == C_VIEW) {
+ view_close(container->sway_view);
+ }
+}
+
+struct sway_container *container_close(struct sway_container *con) {
+ if (!sway_assert(con != NULL, "container_close called with a NULL container")) {
+ return NULL;
+ }
+
+ switch (con->type) {
+ case C_TYPES:
+ wlr_log(L_ERROR, "tried to close an invalid container");
+ break;
+ case C_ROOT:
+ wlr_log(L_ERROR, "tried to close the root container");
+ break;
+ case C_OUTPUT:
+ container_output_destroy(con);
+ break;
+ case C_WORKSPACE:
+ container_workspace_destroy(con);
+ break;
+ case C_CONTAINER:
+ container_for_each_descendant_dfs(con, container_close_func, NULL);
+ break;
+ case C_VIEW:
+ view_close(con->sway_view);
+ break;
+
+ }
+
+ return con->parent;
+}
+
struct sway_container *container_output_create(
struct sway_output *sway_output) {
struct wlr_box size;