Bugfix: Don’t attach tiling containers to floating containers

This bug happened when there were only floating containers on a workspace and a
new tiling window was to be opened.
This commit is contained in:
Michael Stapelberg
2010-11-21 16:49:59 +01:00
parent f53fafe100
commit 09b5b17830
3 changed files with 83 additions and 6 deletions

View File

@ -70,14 +70,24 @@ Con *con_new(Con *parent) {
*/
void con_attach(Con *con, Con *parent) {
con->parent = parent;
Con *current = TAILQ_FIRST(&(parent->focus_head));
Con *loop;
Con *current = NULL;
if (current == TAILQ_END(&(parent->focus_head)))
TAILQ_INSERT_TAIL(&(parent->nodes_head), con, nodes);
else {
DLOG("inserting after\n");
TAILQ_INSERT_AFTER(&(parent->nodes_head), current, con, nodes);
/* Get the first tiling container in focus stack */
TAILQ_FOREACH(loop, &(parent->focus_head), focused) {
if (loop->type == CT_FLOATING_CON)
continue;
current = loop;
break;
}
/* Insert the container after the tiling container, if found */
if (current) {
DLOG("Inserting con = %p after last focused tiling con %p\n",
con, current);
TAILQ_INSERT_AFTER(&(parent->nodes_head), current, con, nodes);
} else TAILQ_INSERT_TAIL(&(parent->nodes_head), con, nodes);
/* We insert to the TAIL because con_focus() will correct this.
* This way, we have the option to insert Cons without having
* to focus them. */