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)
{
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;
}
}
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);