From 92a9e09643a88a38d373d08f0f514d2bb7285358 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 18 Apr 2024 11:09:36 +0100 Subject: Merged laptop version with remote Laptop had gapless grid --- gaplessgrid.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 gaplessgrid.c (limited to 'gaplessgrid.c') diff --git a/gaplessgrid.c b/gaplessgrid.c new file mode 100644 index 0000000..5b9de89 --- /dev/null +++ b/gaplessgrid.c @@ -0,0 +1,35 @@ +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) - m->gappx; + cx = (m->wx + cn*cw) + m->gappx; + cy = (m->wy + rn*ch) + m->gappx; + resize(c, cx + m->gappx, cy, cw - 2 * c->bw - m->gappx, ch - 2 * c->bw, False); + rn++; + if(rn >= rows) { + rn = 0; + cn++; + } + } +} -- cgit v1.2.3-13-gbd6f