Bugfix: Check swallows before assignments when managing windows (Thanks julien)

Fixes #395 (empty containers on restart when assigned windows are visible)
This commit is contained in:
Michael Stapelberg 2011-05-25 21:00:53 +02:00
parent 7fca97b151
commit 7ae0c9c973
1 changed files with 23 additions and 22 deletions

View File

@ -207,7 +207,12 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
Match *match; Match *match;
Assignment *assignment; Assignment *assignment;
/* check assignments first */ /* TODO: two matches for one container */
/* See if any container swallows this new window */
nc = con_for_window(search_at, cwindow, &match);
if (nc == NULL) {
/* If not, check if it is assigned to a specific workspace / output */
if ((assignment = assignment_for(cwindow, A_TO_WORKSPACE | A_TO_OUTPUT))) { if ((assignment = assignment_for(cwindow, A_TO_WORKSPACE | A_TO_OUTPUT))) {
DLOG("Assignment matches (%p)\n", match); DLOG("Assignment matches (%p)\n", match);
if (assignment->type == A_TO_WORKSPACE) { if (assignment->type == A_TO_WORKSPACE) {
@ -219,16 +224,13 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
} }
/* TODO: handle assignments with type == A_TO_OUTPUT */ /* TODO: handle assignments with type == A_TO_OUTPUT */
} else { } else {
/* TODO: two matches for one container */ /* If not, insert it at the currently focused position */
/* See if any container swallows this new window */
nc = con_for_window(search_at, cwindow, &match);
if (nc == NULL) {
if (focused->type == CT_CON && con_accepts_window(focused)) { if (focused->type == CT_CON && con_accepts_window(focused)) {
LOG("using current container, focused = %p, focused->name = %s\n", LOG("using current container, focused = %p, focused->name = %s\n",
focused, focused->name); focused, focused->name);
nc = focused; nc = focused;
} else nc = tree_open_con(NULL); } else nc = tree_open_con(NULL);
}
} else { } else {
/* M_BELOW inserts the new window as a child of the one which was /* M_BELOW inserts the new window as a child of the one which was
* matched (e.g. dock areas) */ * matched (e.g. dock areas) */
@ -236,7 +238,6 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
nc = tree_open_con(nc); nc = tree_open_con(nc);
} }
} }
}
DLOG("new container = %p\n", nc); DLOG("new container = %p\n", nc);
nc->window = cwindow; nc->window = cwindow;