dwm-meillo

changeset 650:f3b8c71a69d4

experimental version which allows master clients being increased/decreased
author Anselm R. Garbe <arg@suckless.org>
date Fri, 05 Jan 2007 12:50:39 +0100
parents d6023e0f3cf9
children b9f4efd21473
files config.arg.h config.default.h config.mk dwm.h main.c view.c
diffstat 6 files changed, 45 insertions(+), 25 deletions(-) [+]
line diff
     1.1 --- a/config.arg.h	Thu Jan 04 16:45:28 2007 +0100
     1.2 +++ b/config.arg.h	Fri Jan 05 12:50:39 2007 +0100
     1.3 @@ -19,6 +19,7 @@
     1.4  
     1.5  #define MASTER			600		/* per thousand */
     1.6  #define MODKEY			Mod1Mask
     1.7 +#define NMASTER			1		/* clients in master area */
     1.8  #define SNAP			40		/* pixel */
     1.9  
    1.10  #define KEYS \
    1.11 @@ -30,10 +31,12 @@
    1.12  		{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
    1.13  			" | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \
    1.14  			"-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \
    1.15 +	{ MODKEY,			XK_d,		incnmaster,	{ .i = -1 } }, \
    1.16  	{ MODKEY,			XK_j,		focusnext,	{ 0 } }, \
    1.17  	{ MODKEY,			XK_k,		focusprev,	{ 0 } }, \
    1.18  	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \
    1.19  	{ MODKEY,			XK_g,		resizemaster,	{ .i = 15 } }, \
    1.20 +	{ MODKEY,			XK_i,		incnmaster,	{ .i = 1 } }, \
    1.21  	{ MODKEY,			XK_s,		resizemaster,	{ .i = -15 } }, \
    1.22  	{ MODKEY|ShiftMask,		XK_0,		tag,		{ .i = -1 } }, \
    1.23  	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \
     2.1 --- a/config.default.h	Thu Jan 04 16:45:28 2007 +0100
     2.2 +++ b/config.default.h	Fri Jan 05 12:50:39 2007 +0100
     2.3 @@ -19,6 +19,7 @@
     2.4  
     2.5  #define MASTER			600		/* per thousand */
     2.6  #define MODKEY			Mod1Mask
     2.7 +#define NMASTER			1		/* clients in master area */
     2.8  #define SNAP			20		/* pixel */
     2.9  
    2.10  #define KEYS \
     3.1 --- a/config.mk	Thu Jan 04 16:45:28 2007 +0100
     3.2 +++ b/config.mk	Fri Jan 05 12:50:39 2007 +0100
     3.3 @@ -17,8 +17,8 @@
     3.4  # flags
     3.5  CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
     3.6  LDFLAGS = ${LIBS}
     3.7 -#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
     3.8 -#LDFLAGS = -g ${LIBS}
     3.9 +CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
    3.10 +LDFLAGS = -g ${LIBS}
    3.11  
    3.12  # Solaris
    3.13  #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
     4.1 --- a/dwm.h	Thu Jan 04 16:45:28 2007 +0100
     4.2 +++ b/dwm.h	Fri Jan 05 12:50:39 2007 +0100
     4.3 @@ -96,7 +96,8 @@
     4.4  extern int bx, by, bw, bh, bmw;			/* bar geometry, bar mode label width */
     4.5  extern int screen, sx, sy, sw, sh;		/* screen geometry */
     4.6  extern int wax, way, wah, waw;			/* windowarea geometry */
     4.7 -extern unsigned int master, ntags, numlockmask;	/* master percent, number of tags, dynamic lock mask */
     4.8 +extern unsigned int master, nmaster;		/* master percent, number of master clients */
     4.9 +extern unsigned int ntags, numlockmask;		/* number of tags, dynamic lock mask */
    4.10  extern void (*handler[LASTEvent])(XEvent *);	/* event handler */
    4.11  extern void (*arrange)(void);			/* arrange function, indicates mode  */
    4.12  extern Atom wmatom[WMLast], netatom[NetLast];
    4.13 @@ -159,6 +160,7 @@
    4.14  extern void dotile(void);			/* arranges all windows tiled */
    4.15  extern void focusnext(Arg *arg);		/* focuses next visible client, arg is ignored  */
    4.16  extern void focusprev(Arg *arg);		/* focuses previous visible client, arg is ignored */
    4.17 +extern void incnmaster(Arg *arg);		/* increments nmaster with arg's index value */
    4.18  extern Bool isvisible(Client *c);		/* returns True if client is visible */
    4.19  extern void resizemaster(Arg *arg);		/* resizes the master percent with arg's index value */
    4.20  extern void restack(void);			/* restores z layers of all clients */
     5.1 --- a/main.c	Thu Jan 04 16:45:28 2007 +0100
     5.2 +++ b/main.c	Fri Jan 05 12:50:39 2007 +0100
     5.3 @@ -20,7 +20,7 @@
     5.4  char stext[1024];
     5.5  Bool *seltag;
     5.6  int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah;
     5.7 -unsigned int master, ntags, numlockmask;
     5.8 +unsigned int master, nmaster, ntags, numlockmask;
     5.9  Atom wmatom[WMLast], netatom[NetLast];
    5.10  Bool running = True;
    5.11  Bool issel = True;
    5.12 @@ -133,6 +133,7 @@
    5.13  	sw = DisplayWidth(dpy, screen);
    5.14  	sh = DisplayHeight(dpy, screen);
    5.15  	master = MASTER;
    5.16 +	nmaster = NMASTER;
    5.17  	/* bar */
    5.18  	bx = sx;
    5.19  	by = sy;
     6.1 --- a/view.c	Thu Jan 04 16:45:28 2007 +0100
     6.2 +++ b/view.c	Fri Jan 05 12:50:39 2007 +0100
     6.3 @@ -69,12 +69,16 @@
     6.4  
     6.5  void
     6.6  dotile(void) {
     6.7 -	unsigned int i, n, mpw, th;
     6.8 +	unsigned int i, n, mw, mh, tw, th;
     6.9  	Client *c;
    6.10  
    6.11  	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
    6.12  		n++;
    6.13 -	mpw = (waw * master) / 1000;
    6.14 +	/* window geoms */
    6.15 +	mw = (n > nmaster) ? (waw * master) / 1000 : waw;
    6.16 +	mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
    6.17 +	tw = waw - mw;
    6.18 +	th = (n > nmaster) ? wah / (n - nmaster) : 0;
    6.19  
    6.20  	for(i = 0, c = clients; c; c = c->next)
    6.21  		if(isvisible(c)) {
    6.22 @@ -85,20 +89,16 @@
    6.23  			c->ismax = False;
    6.24  			c->x = wax;
    6.25  			c->y = way;
    6.26 -			if(n == 1) { /* only 1 window */
    6.27 -				c->w = waw - 2 * BORDERPX;
    6.28 -				c->h = wah - 2 * BORDERPX;
    6.29 -			}
    6.30 -			else if(i == 0) { /* master window */
    6.31 -				c->w = mpw - 2 * BORDERPX;
    6.32 -				c->h = wah - 2 * BORDERPX;
    6.33 -				th = wah / (n - 1);
    6.34 +			if(i < nmaster) {
    6.35 +				c->y += i * mh;
    6.36 +				c->w = mw - 2 * BORDERPX;
    6.37 +				c->h = mh - 2 * BORDERPX;
    6.38  			}
    6.39  			else {  /* tile window */
    6.40 -				c->x += mpw;
    6.41 -				c->w = (waw - mpw) - 2 * BORDERPX;
    6.42 +				c->x += mw;
    6.43 +				c->w = tw - 2 * BORDERPX;
    6.44  				if(th > bh) {
    6.45 -					c->y += (i - 1) * th;
    6.46 +					c->y += (i - nmaster) * th;
    6.47  					c->h = th - 2 * BORDERPX;
    6.48  				}
    6.49  				else /* fallback if th < bh */
    6.50 @@ -147,6 +147,14 @@
    6.51  	}
    6.52  }
    6.53  
    6.54 +void
    6.55 +incnmaster(Arg *arg) {
    6.56 +	if(nmaster + arg->i < 1)
    6.57 +		return;
    6.58 +	nmaster += arg->i;
    6.59 +	arrange();
    6.60 +}
    6.61 +
    6.62  Bool
    6.63  isvisible(Client *c) {
    6.64  	unsigned int i;
    6.65 @@ -240,7 +248,7 @@
    6.66  
    6.67  void
    6.68  zoom(Arg *arg) {
    6.69 -	unsigned int n;
    6.70 +	unsigned int i, n;
    6.71  	Client *c;
    6.72  
    6.73  	if(!sel)
    6.74 @@ -249,14 +257,19 @@
    6.75  		togglemax(sel);
    6.76  		return;
    6.77  	}
    6.78 -	for(n = 0, c = clients; c; c = c->next)
    6.79 -		if(isvisible(c) && !c->isfloat)
    6.80 -			n++;
    6.81 -	if(n < 2 || (arrange == dofloat))
    6.82 +	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
    6.83 +		n++;
    6.84 +	if(n <= nmaster || (arrange == dofloat))
    6.85  		return;
    6.86 -	if((c = sel) == nexttiled(clients))
    6.87 -		if(!(c = nexttiled(c->next)))
    6.88 -			return;
    6.89 +
    6.90 +	for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c = nexttiled(c->next))
    6.91 +		i++;
    6.92 +	if(c == sel && i < nmaster)
    6.93 +		for(; c && i < nmaster; c = nexttiled(c->next))
    6.94 +			i++;
    6.95 +	if(!c)
    6.96 +		return;
    6.97 +
    6.98  	detach(c);
    6.99  	if(clients)
   6.100  		clients->prev = c;