Bugfix: don’t kill parent when currently in tree_close() for a child of this parent

next
Michael Stapelberg 2010-11-14 20:14:09 +01:00
parent f0efb3737e
commit d760a1c7b2
6 changed files with 13 additions and 11 deletions

View File

@ -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).

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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 parents 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
* dont 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);
}
}

View File

@ -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);
}
}