]> git.mdlowis.com Git - proto/anvil.git/commitdiff
fixed bug that disallowed deleting an empty column
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 22 Mar 2020 02:41:15 +0000 (22:41 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 22 Mar 2020 02:41:15 +0000 (22:41 -0400)
mons.c

diff --git a/mons.c b/mons.c
index 0f66a50a822c8900b2083f6ef5908b68d0c9cbe2..0f978d8c3c89bfc7647a7715e4c61bcc4a24cf87 100644 (file)
--- a/mons.c
+++ b/mons.c
@@ -271,6 +271,7 @@ void mons_coljoin(void)
 
 void mons_coladjust(Monitor* mon, Column* col, int leftedge, int wdiff)
 {
+    /* TODO: range limit the adjustment here to ensure minimum column size upheld */
     Column* neighbor = col->next;
     if (leftedge)
     {
@@ -307,22 +308,15 @@ static Monitor* pickmon(void)
 static Column* pickcol(Column* cols, int relx)
 {
     Column* col = cols;
-    /* find first empty column, and fill that first */
-    for (; col && col->clients; col = col->next);
-    /* otherwise, return the current column */
-    if (!col)
+    int left = 0, right = 0;
+    for (col = cols; col; col = col->next)
     {
-        int left = 0, right = 0;
-        for (col = cols; col; col = col->next)
+        left = right, right += col->width;
+        if (left <= relx && relx < right)
         {
-            left = right, right += col->width;
-            if (left <= relx && relx < right)
-            {
-                break; /* we found the column holding the mouse */
-            }
+            break; /* we found the column holding the mouse */
         }
     }
-    assert(col);
     return col;
 }
 
@@ -381,7 +375,15 @@ static void add_client(Monitor* mon, Client* c, int ptrx)
     }
     else
     {
-        Column* col = pickcol(mon->cspace->columns, ptrx - mon->x);
+        Column* col = mon->cspace->columns;
+        /* find first empty column, and fill that first */
+        for (; col && col->clients; col = col->next);
+        if (!col)
+        {
+            /* otherwise pick the current column */
+            col = pickcol(mon->cspace->columns, ptrx - mon->x);
+        }
+        /* add in monocled or stacked mode */
         if (col->focused)
         {
             monocled_add(mon, col, c);