* 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
TAILQ_INIT(&(new->swallow_head));
if (parent != NULL)
- con_attach(new, parent);
+ con_attach(new, parent, false);
return new;
}
* 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;
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 */
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);
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);
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);
new->orientation = orientation;
/* 3: add it as a child to the new Con */
- con_attach(con, new);
+ con_attach(con, new, false);
}
/*
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\"}");
}