Bugfix: Re-attach windows in correct order when switching layout (Thanks fernandotcl)

This commit is contained in:
Michael Stapelberg 2010-11-28 01:51:16 +01:00
parent d0de3f403d
commit 3bab222aa7
4 changed files with 25 additions and 15 deletions

View File

@ -86,8 +86,12 @@ int con_num_children(Con *con);
* a container or when inserting a new container at a specific place in the
* tree.
*
* ignore_focus is to just insert the Con at the end (useful when creating a
* new split container *around* some containers, that is, detaching and
* attaching them in order without wanting to mess with the focus in between).
*
*/
void con_attach(Con *con, Con *parent);
void con_attach(Con *con, Con *parent, bool ignore_focus);
/**
* Detaches the given container from its current parent

View File

@ -57,7 +57,7 @@ Con *con_new(Con *parent) {
TAILQ_INIT(&(new->swallow_head));
if (parent != NULL)
con_attach(new, parent);
con_attach(new, parent, false);
return new;
}
@ -67,8 +67,12 @@ Con *con_new(Con *parent) {
* a container or when inserting a new container at a specific place in the
* tree.
*
* ignore_focus is to just insert the Con at the end (useful when creating a
* new split container *around* some containers, that is, detaching and
* attaching them in order without wanting to mess with the focus in between).
*
*/
void con_attach(Con *con, Con *parent) {
void con_attach(Con *con, Con *parent, bool ignore_focus) {
con->parent = parent;
Con *loop;
Con *current = NULL;
@ -102,12 +106,14 @@ void con_attach(Con *con, Con *parent) {
goto add_to_focus_head;
}
/* 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;
if (!ignore_focus) {
/* 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 */
@ -428,7 +434,7 @@ void con_move_to_workspace(Con *con, Con *workspace) {
DLOG("Re-attaching container to %p / %s\n", next, next->name);
/* 4: re-attach the con to the parent of this focused container */
con_detach(con);
con_attach(con, next);
con_attach(con, next, false);
/* 5: keep focus on the current workspace */
con_focus(focus_next);
@ -577,12 +583,12 @@ void con_set_layout(Con *con, int layout) {
while (!TAILQ_EMPTY(&(con->nodes_head))) {
child = TAILQ_FIRST(&(con->nodes_head));
con_detach(child);
con_attach(child, new);
con_attach(child, new, true);
}
/* 4: attach the new split container to the workspace */
DLOG("Attaching new split to ws\n");
con_attach(new, con);
con_attach(new, con, false);
if (old_focused)
con_focus(old_focused);

View File

@ -86,7 +86,7 @@ void tree_init() {
ws->num = c;
asprintf(&(ws->name), "%d", c);
c++;
con_attach(ws, oc);
con_attach(ws, oc, false);
asprintf(&name, "[i3 con] workspace %s", ws->name);
x_set_name(ws, name);
@ -269,7 +269,7 @@ void tree_split(Con *con, orientation_t orientation) {
new->orientation = orientation;
/* 3: add it as a child to the new Con */
con_attach(con, new);
con_attach(con, new, false);
}
/*

View File

@ -59,7 +59,7 @@ Con *workspace_get(const char *num) {
else workspace->num = parsed_num;
LOG("num = %d\n", workspace->num);
workspace->orientation = HORIZ;
con_attach(workspace, output);
con_attach(workspace, output, false);
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}");
}