]> git.mdlowis.com Git - proto/anvil.git/commitdiff
allow joining last column while it's focused
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 29 Mar 2020 02:56:29 +0000 (22:56 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 29 Mar 2020 02:56:29 +0000 (22:56 -0400)
mons.c

diff --git a/mons.c b/mons.c
index 14d3bf228aff2c3388452575d097966ad843aa37..fca94b6ffbae0247f130ef024b8c0751ec046e83 100644 (file)
--- a/mons.c
+++ b/mons.c
@@ -254,28 +254,34 @@ void mons_colsplit(void)
 void mons_coljoin(void)
 {
     Monitor* mon = pickmon();
-    Column* col = pickcol(mon->cspace->columns, PtrX);
-    if (col->next)
+    Column* dest = pickcol(mon->cspace->columns, PtrX);
+    Column* dead = dest->next;
+    if (!dead)
+    {
+        dead = dest;
+        dest = list_prev(mon->cspace->columns, dead);
+    }
+
+    if (dest && dead)
     {
         /* add the clients to the current col */
-        for (Client* c = col->next->clients; c;)
+        for (Client* c = dead->clients; c;)
         {
             Client* next = c->next;
-            if (col->focused)
+            if (dest->focused)
             {
-                monocled_add(mon, col, c);
+                monocled_add(mon, dest, c);
             }
             else
             {
-                stacked_add(mon, col, c);
+                stacked_add(mon, dest, c);
             }
             c = next;
         }
-        Column* dead = col->next;
-        col->next = dead->next;
-        col->width += dead->width;
+        dest->next = dead->next;
+        dest->width += dead->width;
         free(dead);
-        adjust_all(col, 0);
+        adjust_all(dest, 0);
     }
 }