]> git.mdlowis.com Git - proto/anvil.git/commitdiff
added method to switch back to stacked mode
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 24 Mar 2020 03:28:12 +0000 (23:28 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 24 Mar 2020 03:28:12 +0000 (23:28 -0400)
tile.c

diff --git a/tile.c b/tile.c
index f2ff479c96a73ff8caa34d0f455589b19adaedd6..2788d8937b7cb7ba20316fa0c5c698c39f7c5979 100644 (file)
--- a/tile.c
+++ b/tile.c
@@ -40,7 +40,6 @@ void monocled_set(Monitor* mon, Column* col, Client* c)
 
 void stacked_add(Monitor* mon, Column* col, Client* c)
 {
-    /* TODO: unshade when client before is is removed */
     /* TODO: add floating client add function */
     coldims(mon, col, &(c->x), &(c->y), &(c->w), &(c->h));
     if (col->clients)
@@ -106,15 +105,28 @@ void stacked_del(Monitor* mon, Column* col, Client* c)
         for (; prev->next != c; prev = prev->next);
         prev->next = c->next;
         prev->h += c->h;
+        client_setshade(prev, 0);
         client_adjust(prev);
     }
 }
 
 void stacked_set(Monitor* mon, Column* col, Client* c)
 {
-    (void)mon, (void)col, (void)c;
-    puts("switching to stacked mode");
-    /* TODO: implement switch back to stacked mode */
+    (void)c;
+    col->focused = NULL;
+    int nclients = 0;
+    for (Client* c = col->clients->next; c; c = c->next, nclients++);
+    int starty = (mon->y + mon->h) - (nclients * MIN_HEIGHT);
+    col->clients->h = starty - mon->y - 1;
+    client_adjust(col->clients);
+    for (Client* c = col->clients->next; c; c = c->next)
+    {
+        c->y = starty;
+        c->h = MIN_HEIGHT;
+        client_setshade(c, 0);
+        client_adjust(c);
+        starty += MIN_HEIGHT;
+    }
 }
 
 void stacked_addheight(Monitor* mon, Column* col, Client* c, int amount)