Introduce splith/splitv layouts, remove orientation

With this commit, the "default" layout is replaced by the splith and
splitv layouts. splith is equivalent to default with orientation
horizontal and splitv is equivalent to default with orientation
vertical.

The "split h" and "split v" commands continue to work as before, they
split the current container and you will end up in a split container
with layout splith (after "split h") or splitv (after "split v").

To change a splith container into a splitv container, use either "layout
splitv" or "layout toggle split". The latter command is used in the
default config as mod+l (previously "layout default"). In case you have
"layout default" in your config file, it is recommended to just replace
it by "layout toggle split", which will work as "layout default" did
before when pressing it once, but toggle between horizontal/vertical
when pressing it repeatedly.

The rationale behind this commit is that it’s cleaner to have all
parameters that influence how windows are rendered in the layout itself
rather than having a special parameter in combination with only one
layout. This enables us to change existing split containers in all cases
without breaking existing features (see ticket #464). Also, users should
feel more confident about whether they are actually splitting or just
changing an existing split container now.

As a nice side-effect, this commit brings back the "layout toggle"
feature we once had in i3 version 3 (see the userguide).

AFAIK, it is safe to use in-place restart to upgrade into versions
after this commit (switching to an older version will break your layout,
though).

Fixes #464
This commit is contained in:
Michael Stapelberg
2012-08-04 03:04:00 +02:00
parent 077e021e26
commit de94f6da1a
22 changed files with 458 additions and 156 deletions

View File

@ -256,7 +256,6 @@ void output_init_con(Output *output) {
Con *topdock = con_new(NULL, NULL);
topdock->type = CT_DOCKAREA;
topdock->layout = L_DOCKAREA;
topdock->orientation = VERT;
/* this container swallows dock clients */
Match *match = scalloc(sizeof(Match));
match_init(match);
@ -278,6 +277,7 @@ void output_init_con(Output *output) {
DLOG("adding main content container\n");
Con *content = con_new(NULL, NULL);
content->type = CT_CON;
content->layout = L_SPLITH;
FREE(content->name);
content->name = sstrdup("content");
@ -290,7 +290,6 @@ void output_init_con(Output *output) {
Con *bottomdock = con_new(NULL, NULL);
bottomdock->type = CT_DOCKAREA;
bottomdock->layout = L_DOCKAREA;
bottomdock->orientation = VERT;
/* this container swallows dock clients */
match = scalloc(sizeof(Match));
match_init(match);
@ -447,11 +446,11 @@ static void output_change_mode(xcb_connection_t *conn, Output *output) {
if (con_num_children(workspace) > 1)
continue;
workspace->orientation = (output->rect.height > output->rect.width) ? VERT : HORIZ;
DLOG("Setting workspace [%d,%s]'s orientation to %d.\n", workspace->num, workspace->name, workspace->orientation);
workspace->layout = (output->rect.height > output->rect.width) ? L_SPLITV : L_SPLITH;
DLOG("Setting workspace [%d,%s]'s layout to %d.\n", workspace->num, workspace->name, workspace->layout);
if ((child = TAILQ_FIRST(&(workspace->nodes_head)))) {
child->orientation = workspace->orientation;
DLOG("Setting child [%d,%s]'s orientation to %d.\n", child->num, child->name, child->orientation);
child->layout = workspace->layout;
DLOG("Setting child [%d,%s]'s layout to %d.\n", child->num, child->name, child->layout);
}
}
}