diff --git a/include/config.h b/include/config.h index 55d597eb..97da3dd2 100644 --- a/include/config.h +++ b/include/config.h @@ -92,7 +92,7 @@ struct Config { const char *ipc_socket_path; const char *restart_state_path; - int container_mode; + int default_layout; int container_stack_limit; int container_stack_limit_value; diff --git a/src/cfgparse.l b/src/cfgparse.l index cc0dd320..7295fed9 100644 --- a/src/cfgparse.l +++ b/src/cfgparse.l @@ -106,9 +106,10 @@ workspace_bar { return TOKWORKSPACEBAR; } popup_during_fullscreen { return TOK_POPUP_DURING_FULLSCREEN; } ignore { return TOK_IGNORE; } leave_fullscreen { return TOK_LEAVE_FULLSCREEN; } -default { /* yylval.number = MODE_DEFAULT; */return TOKCONTAINERMODE; } -stacking { /* yylval.number = MODE_STACK; */return TOKCONTAINERMODE; } -tabbed { /* yylval.number = MODE_TABBED; */return TOKCONTAINERMODE; } +default { /* yylval.number = MODE_DEFAULT; */return TOK_DEFAULT; } +stacking { /* yylval.number = MODE_STACK; */return TOK_STACKING; } +stacked { return TOK_STACKING; } +tabbed { /* yylval.number = MODE_TABBED; */return TOK_TABBED; } stack-limit { return TOKSTACKLIMIT; } cols { /* yylval.number = STACK_LIMIT_COLS; */return TOKSTACKLIMIT; } rows { /* yylval.number = STACK_LIMIT_ROWS; */return TOKSTACKLIMIT; } diff --git a/src/cfgparse.y b/src/cfgparse.y index 68678b80..75e68122 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -235,7 +235,9 @@ void parse_file(const char *f) { %token TOK_1PIXEL "1pixel" %token TOKFOCUSFOLLOWSMOUSE "focus_follows_mouse" %token TOKWORKSPACEBAR "workspace_bar" -%token TOKCONTAINERMODE "default/stacking/tabbed" +%token TOK_DEFAULT "default" +%token TOK_STACKING "stacking" +%token TOK_TABBED "tabbed" %token TOKSTACKLIMIT "stack-limit" %token TOK_POPUP_DURING_FULLSCREEN "popup_during_fullscreen" %token TOK_IGNORE "ignore" @@ -393,10 +395,10 @@ direction: ; new_container: - TOKNEWCONTAINER WHITESPACE TOKCONTAINERMODE + TOKNEWCONTAINER WHITESPACE layout_mode { DLOG("new containers will be in mode %d\n", $3); - config.container_mode = $3; + config.default_layout = $3; #if 0 /* We also need to change the layout of the already existing @@ -437,6 +439,12 @@ new_container: } ; +layout_mode: + TOK_DEFAULT { $$ = L_DEFAULT; } + | TOK_STACKING { $$ = L_STACKED; } + | TOK_TABBED { $$ = L_TABBED; } + ; + new_window: TOKNEWWINDOW WHITESPACE border_style { diff --git a/src/con.c b/src/con.c index d5029eea..07406d8d 100644 --- a/src/con.c +++ b/src/con.c @@ -59,8 +59,16 @@ 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. */ + if (parent->type == CT_WORKSPACE && con_is_leaf(parent)) { + 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; }