diff --git a/include/tree.h b/include/tree.h index 449f67ef..f04e9e62 100644 --- a/include/tree.h +++ b/include/tree.h @@ -76,7 +76,7 @@ void tree_move(char way, orientation_t orientation); * Closes the given container including all children * */ -void tree_close(Con *con, bool kill_window); +void tree_close(Con *con, bool kill_window, bool dont_kill_parent); /** * Loads tree from ~/.i3/_restart.json (used for in-place restarts). diff --git a/src/cmdparse.y b/src/cmdparse.y index e5c9aa5c..7f9dfd46 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -382,7 +382,7 @@ kill: else { TAILQ_FOREACH(current, &owindows, owindows) { printf("matching: %p / %s\n", current->con, current->con->name); - tree_close(current->con, true); + tree_close(current->con, true, false); } } diff --git a/src/floating.c b/src/floating.c index 756102b7..005f2092 100644 --- a/src/floating.c +++ b/src/floating.c @@ -95,7 +95,7 @@ void floating_disable(Con *con, bool automatic) { /* 2: kill parent container */ TAILQ_REMOVE(&(con->parent->parent->floating_head), con->parent, floating_windows); TAILQ_REMOVE(&(con->parent->parent->focus_head), con->parent, focused); - tree_close(con->parent, false); + tree_close(con->parent, false, false); /* 3: re-attach to previous parent */ con->parent = con->old_parent; diff --git a/src/handlers.c b/src/handlers.c index 72cc68c5..f5324dfe 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -436,7 +436,7 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti return 1; } - tree_close(con, false); + tree_close(con, false, false); tree_render(); x_push_changes(croot); return 1; diff --git a/src/tree.c b/src/tree.c index f7f7a759..3f860923 100644 --- a/src/tree.c +++ b/src/tree.c @@ -143,7 +143,7 @@ static void fix_floating_parent(Con *con, Con *vanishing) { * Closes the given container including all children * */ -void tree_close(Con *con, bool kill_window) { +void tree_close(Con *con, bool kill_window, bool dont_kill_parent) { Con *parent = con->parent; /* check floating clients and adjust old_parent if necessary */ @@ -158,7 +158,8 @@ void tree_close(Con *con, bool kill_window) { * in their parent’s nodes_head */ while (!TAILQ_EMPTY(&(con->nodes_head))) { child = TAILQ_FIRST(&(con->nodes_head)); - tree_close(child, kill_window); + DLOG("killing child=%p\n", child); + tree_close(child, kill_window, true); } if (con->window != NULL) { @@ -199,12 +200,13 @@ void tree_close(Con *con, bool kill_window) { con_focus(next); /* check if the parent container is empty now and close it */ - if (parent->type != CT_WORKSPACE && + if (!dont_kill_parent && + parent->type != CT_WORKSPACE && TAILQ_EMPTY(&(parent->nodes_head))) { DLOG("Closing empty parent container\n"); /* TODO: check if this container would swallow any other client and * don’t close it automatically. */ - tree_close(parent, false); + tree_close(parent, false, false); } } @@ -220,7 +222,7 @@ void tree_close_con() { } /* Kill con */ - tree_close(focused, true); + tree_close(focused, true, false); } /* @@ -443,6 +445,6 @@ void tree_move(char way, orientation_t orientation) { if (con_num_children(old_parent) == 0) { DLOG("Old container empty after moving. Let's close it\n"); - tree_close(old_parent, false); + tree_close(old_parent, false, false); } } diff --git a/src/workspace.c b/src/workspace.c index d98c7562..cdea9827 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -209,7 +209,7 @@ void workspace_show(const char *num) { /* check if this workspace is currently visible */ if (!workspace_is_visible(old)) { LOG("Closing old workspace (%p / %s), it is empty\n", old, old->name); - tree_close(old, false); + tree_close(old, false, false); } }