sites

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

dwm-ru_gaplessgrid-6.2.diff (1938B)


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