]> git.sur5r.net Git - i3/i3/commitdiff
Implemented config key 'new_container'
authorSimon Kampe <simon.kampe@gmail.com>
Wed, 23 Mar 2011 15:11:46 +0000 (16:11 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Sat, 2 Apr 2011 19:43:49 +0000 (21:43 +0200)
include/config.h
src/cfgparse.l
src/cfgparse.y
src/con.c

index 55d597ebfecc2063894b72d7876a6f89732dae0e..97da3dd2f02aeeeb3e2b947898f115e79707c893 100644 (file)
@@ -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;
 
index cc0dd320b2e110b6d9b5e7d37727d22a3c622ccb..7295fed9aa33d39408a47587dc844b8f97a855ee 100644 (file)
@@ -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; }
index 68678b801dde3eb21b1b5cf1ef753572bb7b99d8..75e68122aa223993b7aff4a5a24aa036fb3f6ca8 100644 (file)
@@ -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", $<number>3);
-                config.container_mode = $<number>3;
+                config.default_layout = $<number>3;
 
 #if 0
                 /* We also need to change the layout of the already existing
@@ -437,6 +439,12 @@ new_container:
         }
         ;
 
+layout_mode:
+      TOK_DEFAULT       { $<number>$ = L_DEFAULT; }
+      | TOK_STACKING    { $<number>$ = L_STACKED; }
+      | TOK_TABBED      { $<number>$ = L_TABBED; }
+      ;
+
 new_window:
         TOKNEWWINDOW WHITESPACE border_style
         {
index d5029eea2df7eb3936926e6e3bddf43c70c13f43..07406d8d94d1765af305fc630a1c9d7ba43b961c 100644 (file)
--- 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;
 }