X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcon.c;h=45021f5f71320cf56cbde11e2a4a392fe653e593;hb=08f64f011d00da966b474d4f93f7f55b78387fb7;hp=d5029eea2df7eb3936926e6e3bddf43c70c13f43;hpb=99ce340feac8f9d28b4558d380532bb14ebf85d6;p=i3%2Fi3 diff --git a/src/con.c b/src/con.c index d5029eea..45021f5f 100644 --- a/src/con.c +++ b/src/con.c @@ -59,8 +59,19 @@ Con *con_new(Con *parent) { TAILQ_INIT(&(new->focus_head)); TAILQ_INIT(&(new->swallow_head)); - if (parent != NULL) - con_attach(new, parent, false); + if (parent != NULL) { + /* Set layout of ws if this is the first child of the ws and the user + * wanted something different than the default layout. */ + if (parent->type == CT_WORKSPACE && + con_is_leaf(parent) && + config.default_layout != L_DEFAULT) { + con_set_layout(new, config.default_layout); + con_attach(new, parent, false); + con_set_layout(parent, config.default_layout); + } else { + con_attach(new, parent, false); + } + } return new; } @@ -538,8 +549,10 @@ void con_move_to_workspace(Con *con, Con *workspace) { Con *next = con_descend_focused(workspace); /* 3: we go up one level, but only when next is a normal container */ - if (next->type != CT_WORKSPACE) + if (next->type != CT_WORKSPACE) { + DLOG("next originally = %p / %s / type %d\n", next, next->name, next->type); next = next->parent; + } /* 4: if the target container is floating, we get the workspace instead. * Only tiling windows need to get inserted next to the current container. @@ -550,6 +563,12 @@ void con_move_to_workspace(Con *con, Con *workspace) { next = floatingcon->parent; } + if (con->type == CT_FLOATING_CON) { + Con *ws = con_get_workspace(next); + DLOG("This is a floating window, using workspace %p / %s\n", ws, ws->name); + next = ws; + } + DLOG("Re-attaching container to %p / %s\n", next, next->name); /* 5: re-attach the con to the parent of this focused container */ Con *parent = con->parent; @@ -570,7 +589,7 @@ void con_move_to_workspace(Con *con, Con *workspace) { * don’t want to focus invisible workspaces */ if (source_output != dest_output && workspace_is_visible(workspace)) { - DLOG("Moved to a different output, focusing target"); + DLOG("Moved to a different output, focusing target\n"); } else { con_focus(focus_next); } @@ -623,6 +642,10 @@ Con *con_next_focused(Con *con) { DLOG("Focus list empty, returning ws\n"); next = ws; } + } else { + /* Instead of returning the next CT_FLOATING_CON, we descend it to + * get an actual window to focus. */ + next = con_descend_focused(next); } return next; } @@ -862,7 +885,7 @@ static void con_on_remove_child(Con *con) { int children = con_num_children(con); if (children == 0) { DLOG("Container empty, closing\n"); - tree_close(con, false, false); + tree_close(con, DONT_KILL_WINDOW, false); return; } }