You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.1 KiB
54 lines
1.1 KiB
9 months ago
|
void
|
||
|
nrowgrid(Monitor *m)
|
||
|
{
|
||
|
unsigned int n = 0, i = 0, ri = 0, ci = 0; /* counters */
|
||
|
int oh, ov, ih, iv; /* vanitygap settings */
|
||
|
unsigned int cx, cy, cw, ch; /* client geometry */
|
||
|
unsigned int uw = 0, uh = 0, uc = 0; /* utilization trackers */
|
||
|
unsigned int cols, rows = m->nmaster + 1;
|
||
|
Client *c;
|
||
|
|
||
|
/* count clients */
|
||
|
getgaps(m, &oh, &ov, &ih, &iv, &n);
|
||
|
|
||
|
/* nothing to do here */
|
||
|
if (n == 0)
|
||
|
return;
|
||
|
|
||
|
/* force 2 clients to always split vertically */
|
||
|
if (FORCE_VSPLIT && n == 2)
|
||
|
rows = 1;
|
||
|
|
||
|
/* never allow empty rows */
|
||
|
if (n < rows)
|
||
|
rows = n;
|
||
|
|
||
|
/* define first row */
|
||
|
cols = n / rows;
|
||
|
uc = cols;
|
||
|
cy = m->wy + oh;
|
||
|
ch = (m->wh - 2*oh - ih*(rows - 1)) / rows;
|
||
|
uh = ch;
|
||
|
|
||
|
for (c = nexttiled(m->clients); c; c = nexttiled(c->next), i++, ci++) {
|
||
|
if (ci == cols) {
|
||
|
uw = 0;
|
||
|
ci = 0;
|
||
|
ri++;
|
||
|
|
||
|
/* next row */
|
||
|
cols = (n - uc) / (rows - ri);
|
||
|
uc += cols;
|
||
|
cy = m->wy + oh + uh + ih;
|
||
|
uh += ch + ih;
|
||
|
}
|
||
|
|
||
|
cx = m->wx + ov + uw;
|
||
|
cw = (m->ww - 2*ov - uw) / (cols - ci);
|
||
|
uw += cw + iv;
|
||
|
|
||
|
resize(c, cx, cy, cw - (2*c->bw), ch - (2*c->bw), 0);
|
||
|
}
|
||
|
}
|
||
|
|