]> git.sur5r.net Git - i3/i3/commitdiff
Implement mode toggle
authorMichael Stapelberg <michael@stapelberg.de>
Mon, 31 May 2010 20:48:28 +0000 (22:48 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Mon, 31 May 2010 20:48:28 +0000 (22:48 +0200)
src/cmdparse.l
src/cmdparse.y
src/floating.c

index 55b1d28f65d0e9bb29056ab9b69154cbbc954d3d..0102d14558e8185fb4842e290743839727caa311 100644 (file)
@@ -95,6 +95,7 @@ none                            { return TOK_NONE; }
 mode                            { return TOK_MODE; }
 tiling                          { return TOK_TILING; }
 floating                        { return TOK_FLOATING; }
+toggle                          { return TOK_TOGGLE; }
 workspace                       { BEGIN(WANT_WS_STRING); return TOK_WORKSPACE; }
 focus                           { return TOK_FOCUS; }
 move                            { return TOK_MOVE; }
index 31d7535b3e4171f32eb6116098aabae63298b109..cc710a49bcf658f386cdc0d1d1ac00a419f176c8 100644 (file)
@@ -109,6 +109,7 @@ void parse_cmd(const char *new) {
 %token TOK_TILING "tiling"
 %token TOK_FLOATING "floating"
 %token TOK_WORKSPACE "workspace"
+%token TOK_TOGGLE "toggle"
 %token TOK_FOCUS "focus"
 %token TOK_MOVE "move"
 %token TOK_OPEN "open"
@@ -398,14 +399,20 @@ direction:
 mode:
     TOK_MODE WHITESPACE window_mode
     {
-        printf("should switch mode to %s\n", ($<number>3 == TOK_FLOATING ? "floating" : "tiling"));
-        /* TODO: actually switch mode (not toggle) */
+        if ($<number>3 == TOK_TOGGLE) {
+            printf("should toggle mode\n");
+            toggle_floating_mode(focused, false);
+        } else {
+            printf("should switch mode to %s\n", ($<number>3 == TOK_FLOATING ? "floating" : "tiling"));
+            /* TODO: actually switch mode (not toggle) */
+        }
     }
     ;
 
 window_mode:
     TOK_FLOATING    { $<number>$ = TOK_FLOATING; }
     | TOK_TILING    { $<number>$ = TOK_TILING; }
+    | TOK_TOGGLE    { $<number>$ = TOK_TOGGLE; }
     ;
 
 level:
index 2afe1b8218876bd9be0b12278805fe8c2f8246b9..416873e53f6ffc452877958fdeac38f4ca2dd7cc 100644 (file)
@@ -37,6 +37,7 @@ void toggle_floating_mode(Con *con, bool automatic) {
 
                 /* 2: kill parent container */
                 TAILQ_REMOVE(&(con->parent->parent->floating_head), con->parent, floating_windows);
+                TAILQ_REMOVE(&(con->parent->parent->focus_head), con->parent, focused);
                 tree_close(con->parent, false);
 
                 /* 3: re-attach to previous parent */
@@ -44,6 +45,8 @@ void toggle_floating_mode(Con *con, bool automatic) {
                 TAILQ_INSERT_TAIL(&(con->parent->nodes_head), con, nodes);
                 TAILQ_INSERT_TAIL(&(con->parent->focus_head), con, focused);
 
+                con->floating = FLOATING_USER_OFF;
+
                 return;
         }
 
@@ -72,6 +75,7 @@ void toggle_floating_mode(Con *con, bool automatic) {
         nc->orientation = NO_ORIENTATION;
         nc->type = CT_FLOATING_CON;
         TAILQ_INSERT_TAIL(&(nc->parent->floating_head), nc, floating_windows);
+        TAILQ_INSERT_TAIL(&(nc->parent->focus_head), nc, focused);
 
         /* 3: attach the child to the new parent container */
         con->old_parent = con->parent;