sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-gaplessgrid-20160731-56a31dc.diff (1108B)


      1 URL: http://dwm.suckless.org/patches/gapless_grid
      2 Add gapless grid layout.
      3 
      4 Index: dwm/gaplessgrid.c
      5 ===================================================================
      6 --- /dev/null
      7 +++ dwm/gaplessgrid.c
      8 @@ -0,0 +1,35 @@
      9 +void
     10 +gaplessgrid(Monitor *m) {
     11 +	unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
     12 +	Client *c;
     13 +
     14 +	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
     15 +	if(n == 0)
     16 +		return;
     17 +
     18 +	/* grid dimensions */
     19 +	for(cols = 0; cols <= n/2; cols++)
     20 +		if(cols*cols >= n)
     21 +			break;
     22 +	if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
     23 +		cols = 2;
     24 +	rows = n/cols;
     25 +
     26 +	/* window geometries */
     27 +	cw = cols ? m->ww / cols : m->ww;
     28 +	cn = 0; /* current column number */
     29 +	rn = 0; /* current row number */
     30 +	for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
     31 +		if(i/rows + 1 > cols - n%cols)
     32 +			rows = n/cols + 1;
     33 +		ch = rows ? m->wh / rows : m->wh;
     34 +		cx = m->wx + cn*cw;
     35 +		cy = m->wy + rn*ch;
     36 +		resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
     37 +		rn++;
     38 +		if(rn >= rows) {
     39 +			rn = 0;
     40 +			cn++;
     41 +		}
     42 +	}
     43 +}