Add parameter to reparent windows instead of killing them when closing a container

Necessary because when windows are unmapped, they are not necessary to
be killed (an application can unmap it temporarily).
This commit is contained in:
Michael Stapelberg 2010-05-15 00:16:59 +02:00
parent def41582d1
commit 2d52ecf071
6 changed files with 21 additions and 13 deletions

View File

@ -21,7 +21,7 @@ void tree_render();
void tree_close_con(); void tree_close_con();
void tree_next(char way, orientation_t orientation); void tree_next(char way, orientation_t orientation);
void tree_move(char way, orientation_t orientation); void tree_move(char way, orientation_t orientation);
void tree_close(Con *con); void tree_close(Con *con, bool kill_window);
bool tree_restore(); bool tree_restore();
#endif #endif

View File

@ -314,11 +314,11 @@ kill:
printf("killing!\n"); printf("killing!\n");
/* check if the match is empty, not if the result is empty */ /* check if the match is empty, not if the result is empty */
if (match_is_empty(&current_match)) if (match_is_empty(&current_match))
tree_close(focused); tree_close(focused, true);
else { else {
TAILQ_FOREACH(current, &owindows, owindows) { TAILQ_FOREACH(current, &owindows, owindows) {
printf("matching: %p / %s\n", current->con, current->con->name); printf("matching: %p / %s\n", current->con, current->con->name);
tree_close(current->con); tree_close(current->con, true);
} }
} }

View File

@ -37,7 +37,7 @@ void toggle_floating_mode(Con *con, bool automatic) {
/* 2: kill parent container */ /* 2: kill parent container */
TAILQ_REMOVE(&(con->parent->parent->floating_head), con->parent, floating_windows); TAILQ_REMOVE(&(con->parent->parent->floating_head), con->parent, floating_windows);
tree_close(con->parent); tree_close(con->parent, false);
/* 3: re-attach to previous parent */ /* 3: re-attach to previous parent */
con->parent = con->old_parent; con->parent = con->old_parent;

View File

@ -469,7 +469,7 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti
return 1; return 1;
} }
tree_close(con); tree_close(con, false);
tree_render(); tree_render();
x_push_changes(croot); x_push_changes(croot);
return 1; return 1;

View File

@ -108,7 +108,7 @@ Con *tree_open_con(Con *con) {
* Closes the given container including all children * Closes the given container including all children
* *
*/ */
void tree_close(Con *con) { void tree_close(Con *con, bool kill_window) {
/* TODO: check floating clients and adjust old_parent if necessary */ /* TODO: check floating clients and adjust old_parent if necessary */
/* Get the container which is next focused */ /* Get the container which is next focused */
@ -129,7 +129,19 @@ void tree_close(Con *con) {
* in their parents nodes_head */ * in their parents nodes_head */
while (!TAILQ_EMPTY(&(con->nodes_head))) { while (!TAILQ_EMPTY(&(con->nodes_head))) {
child = TAILQ_FIRST(&(con->nodes_head)); child = TAILQ_FIRST(&(con->nodes_head));
tree_close(child); tree_close(child, kill_window);
}
if (con->window != NULL) {
if (kill_window)
x_window_kill(con->window->id);
else {
/* un-parent the window */
xcb_reparent_window(conn, con->window->id, root, 0, 0);
/* TODO: client_unmap to set state to withdrawn */
}
free(con->window);
} }
/* kill the X11 part of this container */ /* kill the X11 part of this container */
@ -138,10 +150,6 @@ void tree_close(Con *con) {
con_detach(con); con_detach(con);
con_fix_percent(con->parent, WINDOW_REMOVE); con_fix_percent(con->parent, WINDOW_REMOVE);
if (con->window != NULL) {
x_window_kill(con->window->id);
free(con->window);
}
free(con->name); free(con->name);
TAILQ_REMOVE(&all_cons, con, all_cons); TAILQ_REMOVE(&all_cons, con, all_cons);
free(con); free(con);
@ -158,7 +166,7 @@ void tree_close_con() {
} }
/* Kill con */ /* Kill con */
tree_close(focused); tree_close(focused, true);
} }
/* /*

View File

@ -117,7 +117,7 @@ void workspace_show(const char *num) {
if (TAILQ_EMPTY(&(old->nodes_head))) { if (TAILQ_EMPTY(&(old->nodes_head))) {
LOG("Closing old workspace (%p / %s), it is empty\n", old, old->name); LOG("Closing old workspace (%p / %s), it is empty\n", old, old->name);
tree_close(old); tree_close(old, false);
} }
con_focus(next); con_focus(next);