Adding gappless grid layout
parent
cccb8fcecb
commit
9081aef748
@ -1 +1,2 @@
|
||||
static void getfacts(Monitor *m, float *mf, float *sf)
|
||||
static void setcfact(const Arg *arg);
|
@ -0,0 +1,76 @@
|
||||
#if VANITYGAPS_PATCH
|
||||
void
|
||||
gaplessgrid(Monitor *m)
|
||||
{
|
||||
unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
|
||||
int oh, ov, ih, iv;
|
||||
Client *c;
|
||||
|
||||
getgaps(m, &oh, &ov, &ih, &iv, &n);
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
/* grid dimensions */
|
||||
for (cols = 0; cols <= n/2; cols++)
|
||||
if (cols*cols >= n)
|
||||
break;
|
||||
if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
|
||||
cols = 2;
|
||||
rows = n/cols;
|
||||
|
||||
/* window geometries */
|
||||
cw = cols ? (m->ww - 2*ov - iv*(cols - 1)) / cols : m->ww - 2*ov;
|
||||
cn = 0; /* current column number */
|
||||
rn = 0; /* current row number */
|
||||
for (i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
|
||||
if (i/rows + 1 > cols - n%cols)
|
||||
rows = n/cols + 1;
|
||||
ch = rows ? (m->wh - 2*oh - ih*(rows - 1)) / rows : m->wh - 2*oh;
|
||||
cx = m->wx + ov + cn*(cw + iv);
|
||||
cy = m->wy + oh + rn*(ch + ih);
|
||||
resize(c, cx, cy, cw - 2*c->bw, ch - 2*c->bw, False);
|
||||
rn++;
|
||||
if (rn >= rows) {
|
||||
rn = 0;
|
||||
cn++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void
|
||||
gaplessgrid(Monitor *m) {
|
||||
unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
|
||||
Client *c;
|
||||
|
||||
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
|
||||
if(n == 0)
|
||||
return;
|
||||
|
||||
/* grid dimensions */
|
||||
for(cols = 0; cols <= n/2; cols++)
|
||||
if(cols*cols >= n)
|
||||
break;
|
||||
if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
|
||||
cols = 2;
|
||||
rows = n/cols;
|
||||
|
||||
/* window geometries */
|
||||
cw = cols ? m->ww / cols : m->ww;
|
||||
cn = 0; /* current column number */
|
||||
rn = 0; /* current row number */
|
||||
for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
|
||||
if(i/rows + 1 > cols - n%cols)
|
||||
rows = n/cols + 1;
|
||||
ch = rows ? m->wh / rows : m->wh;
|
||||
cx = m->wx + cn*cw;
|
||||
cy = m->wy + rn*ch;
|
||||
resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
|
||||
rn++;
|
||||
if(rn >= rows) {
|
||||
rn = 0;
|
||||
cn++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -0,0 +1 @@
|
||||
static void gaplessgrid(Monitor *m);
|
Loading…
Reference in New Issue