dwm-ru_gapelessgrid-6.2.diff (1703B)
1 diff -up a/config.def.h b/config.def.h 2 --- a/config.def.h 2019-05-12 17:49:58.316594678 +0200 3 +++ b/config.def.h 2019-05-12 18:00:07.816583101 +0200 4 @@ -39,6 +39,7 @@ static const int resizehints = 1; /* 5 6 static const Layout layouts[] = { 7 /* symbol arrange function */ 8 + { "###", gaplessgrid }, 9 { "[]=", tile }, /* first entry is default */ 10 { "><>", NULL }, /* no layout function means floating behavior */ 11 { "[M]", monocle }, 12 diff -upN a/gaplessgrid.c b/gaplessgrid.c 13 --- a/gaplessgrid.c 1970-01-01 01:00:00.000000000 +0100 14 +++ b/gaplessgrid.c 2019-05-12 13:16:17.589927256 +0200 15 @@ -0,0 +1,40 @@ 16 +void 17 +gaplessgrid(Monitor *m) { 18 + unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch; 19 + Client *c; 20 + 21 + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ; 22 + if(n == 0) 23 + return; 24 + if(n == 1){ 25 + c = nexttiled(m->clients); 26 + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); 27 + return; 28 + } 29 + 30 + /* grid dimensions */ 31 + for(cols = 0; cols <= n/2; cols++) 32 + if(cols*cols >= n) 33 + break; 34 + if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ 35 + cols = 2; 36 + rows = n/cols; 37 + 38 + /* window geometries */ 39 + cw = cols ? m->ww / cols : m->ww; 40 + cn = 0; /* current column number */ 41 + rn = 0; /* current row number */ 42 + for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) { 43 + if(i/rows + 1 > cols - n%cols) 44 + rows = n/cols + 1; 45 + ch = rows ? m->wh / rows : m->wh; 46 + cx = m->wx + cn*cw; 47 + cy = m->wy + rn*ch; 48 + resize(c, cx + m->gappx, cy + m->gappx, cw - 2 * (c->bw + m->gappx), ch - 2 * (c->bw + m->gappx), False); 49 + rn++; 50 + if(rn >= rows) { 51 + rn = 0; 52 + cn++; 53 + } 54 + } 55 +}