From bb36fae50915ecd1525fed8ccafff7e8ed8d6f77 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Sat, 21 Mar 2020 22:41:15 -0400 Subject: [PATCH] fixed bug that disallowed deleting an empty column --- mons.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/mons.c b/mons.c index 0f66a50..0f978d8 100644 --- 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); -- 2.52.0