Bugfix: randr: Don’t close container if it was not initialized before

This commit is contained in:
Michael Stapelberg 2011-01-06 14:35:04 +01:00
parent 2312187439
commit 55b6d31e4a
1 changed files with 29 additions and 27 deletions

View File

@ -534,36 +534,38 @@ void randr_query_outputs() {
if ((first = get_first_output()) == NULL) if ((first = get_first_output()) == NULL)
die("No usable outputs available\n"); die("No usable outputs available\n");
/* We need to move the workspaces from the disappearing output to the first output */ if (output->con != NULL) {
/* 1: Get the con to focus next, if the disappearing ws is focused */ /* We need to move the workspaces from the disappearing output to the first output */
Con *next = NULL; /* 1: Get the con to focus next, if the disappearing ws is focused */
if (TAILQ_FIRST(&(croot->focus_head)) == output->con) { Con *next = NULL;
DLOG("This output (%p) was focused! Getting next\n", output->con); if (TAILQ_FIRST(&(croot->focus_head)) == output->con) {
next = con_next_focused(output->con); DLOG("This output (%p) was focused! Getting next\n", output->con);
DLOG("next = %p\n", next); next = con_next_focused(output->con);
} DLOG("next = %p\n", next);
}
/* 2: iterate through workspaces and re-assign them */ /* 2: iterate through workspaces and re-assign them */
Con *current; Con *current;
while (!TAILQ_EMPTY(&(output->con->nodes_head))) { while (!TAILQ_EMPTY(&(output->con->nodes_head))) {
current = TAILQ_FIRST(&(output->con->nodes_head)); current = TAILQ_FIRST(&(output->con->nodes_head));
DLOG("Detaching current = %p / %s\n", current, current->name); DLOG("Detaching current = %p / %s\n", current, current->name);
con_detach(current); con_detach(current);
DLOG("Re-attaching current = %p / %s\n", current, current->name); DLOG("Re-attaching current = %p / %s\n", current, current->name);
con_attach(current, first->con, false); con_attach(current, first->con, false);
DLOG("Done, next\n"); DLOG("Done, next\n");
} }
DLOG("re-attached all workspaces\n"); DLOG("re-attached all workspaces\n");
if (next) { if (next) {
DLOG("now focusing next = %p\n", next); DLOG("now focusing next = %p\n", next);
con_focus(next); con_focus(next);
} }
DLOG("destroying disappearing con %p\n", output->con); DLOG("destroying disappearing con %p\n", output->con);
tree_close(output->con, false, true); tree_close(output->con, false, true);
DLOG("Done. Should be fine now\n"); DLOG("Done. Should be fine now\n");
output->con = NULL; output->con = NULL;
}
output->to_be_disabled = false; output->to_be_disabled = false;
} }