experimental version which allows master clients being increased/decreased
This commit is contained in:
		
							parent
							
								
									d7ec23a5db
								
							
						
					
					
						commit
						0b80d1842d
					
				| @ -19,6 +19,7 @@ const char *tags[] = { "dev", "work", "net", "fnord", NULL }; | |||||||
| 
 | 
 | ||||||
| #define MASTER			600		/* per thousand */ | #define MASTER			600		/* per thousand */ | ||||||
| #define MODKEY			Mod1Mask | #define MODKEY			Mod1Mask | ||||||
|  | #define NMASTER			1		/* clients in master area */ | ||||||
| #define SNAP			40		/* pixel */ | #define SNAP			40		/* pixel */ | ||||||
| 
 | 
 | ||||||
| #define KEYS \ | #define KEYS \ | ||||||
| @ -30,10 +31,12 @@ static Key key[] = { \ | |||||||
| 		{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \ | 		{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \ | ||||||
| 			" | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \ | 			" | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \ | ||||||
| 			"-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \ | 			"-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \ | ||||||
|  | 	{ MODKEY,			XK_d,		incnmaster,	{ .i = -1 } }, \ | ||||||
| 	{ MODKEY,			XK_j,		focusnext,	{ 0 } }, \ | 	{ MODKEY,			XK_j,		focusnext,	{ 0 } }, \ | ||||||
| 	{ MODKEY,			XK_k,		focusprev,	{ 0 } }, \ | 	{ MODKEY,			XK_k,		focusprev,	{ 0 } }, \ | ||||||
| 	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \ | 	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \ | ||||||
| 	{ MODKEY,			XK_g,		resizemaster,	{ .i = 15 } }, \ | 	{ MODKEY,			XK_g,		resizemaster,	{ .i = 15 } }, \ | ||||||
|  | 	{ MODKEY,			XK_i,		incnmaster,	{ .i = 1 } }, \ | ||||||
| 	{ MODKEY,			XK_s,		resizemaster,	{ .i = -15 } }, \ | 	{ MODKEY,			XK_s,		resizemaster,	{ .i = -15 } }, \ | ||||||
| 	{ MODKEY|ShiftMask,		XK_0,		tag,		{ .i = -1 } }, \ | 	{ MODKEY|ShiftMask,		XK_0,		tag,		{ .i = -1 } }, \ | ||||||
| 	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \ | 	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \ | ||||||
|  | |||||||
| @ -19,6 +19,7 @@ const char *tags[] = { "1", "2", "3", "4", "5", NULL }; | |||||||
| 
 | 
 | ||||||
| #define MASTER			600		/* per thousand */ | #define MASTER			600		/* per thousand */ | ||||||
| #define MODKEY			Mod1Mask | #define MODKEY			Mod1Mask | ||||||
|  | #define NMASTER			1		/* clients in master area */ | ||||||
| #define SNAP			20		/* pixel */ | #define SNAP			20		/* pixel */ | ||||||
| 
 | 
 | ||||||
| #define KEYS \ | #define KEYS \ | ||||||
|  | |||||||
| @ -17,8 +17,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 | |||||||
| # flags
 | # flags
 | ||||||
| CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" | CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" | ||||||
| LDFLAGS = ${LIBS} | LDFLAGS = ${LIBS} | ||||||
| #CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
 | CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" | ||||||
| #LDFLAGS = -g ${LIBS}
 | LDFLAGS = -g ${LIBS} | ||||||
| 
 | 
 | ||||||
| # Solaris
 | # Solaris
 | ||||||
| #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
 | #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
 | ||||||
|  | |||||||
							
								
								
									
										4
									
								
								dwm.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								dwm.h
									
									
									
									
									
								
							| @ -96,7 +96,8 @@ extern char stext[1024];			/* status text */ | |||||||
| extern int bx, by, bw, bh, bmw;			/* bar geometry, bar mode label width */ | extern int bx, by, bw, bh, bmw;			/* bar geometry, bar mode label width */ | ||||||
| extern int screen, sx, sy, sw, sh;		/* screen geometry */ | extern int screen, sx, sy, sw, sh;		/* screen geometry */ | ||||||
| extern int wax, way, wah, waw;			/* windowarea geometry */ | extern int wax, way, wah, waw;			/* windowarea geometry */ | ||||||
| extern unsigned int master, ntags, numlockmask;	/* master percent, number of tags, dynamic lock mask */ | extern unsigned int master, nmaster;		/* master percent, number of master clients */ | ||||||
|  | extern unsigned int ntags, numlockmask;		/* number of tags, dynamic lock mask */ | ||||||
| extern void (*handler[LASTEvent])(XEvent *);	/* event handler */ | extern void (*handler[LASTEvent])(XEvent *);	/* event handler */ | ||||||
| extern void (*arrange)(void);			/* arrange function, indicates mode  */ | extern void (*arrange)(void);			/* arrange function, indicates mode  */ | ||||||
| extern Atom wmatom[WMLast], netatom[NetLast]; | extern Atom wmatom[WMLast], netatom[NetLast]; | ||||||
| @ -159,6 +160,7 @@ extern void dofloat(void);			/* arranges all windows floating */ | |||||||
| extern void dotile(void);			/* arranges all windows tiled */ | extern void dotile(void);			/* arranges all windows tiled */ | ||||||
| extern void focusnext(Arg *arg);		/* focuses next visible client, arg is ignored  */ | extern void focusnext(Arg *arg);		/* focuses next visible client, arg is ignored  */ | ||||||
| extern void focusprev(Arg *arg);		/* focuses previous visible client, arg is ignored */ | extern void focusprev(Arg *arg);		/* focuses previous visible client, arg is ignored */ | ||||||
|  | extern void incnmaster(Arg *arg);		/* increments nmaster with arg's index value */ | ||||||
| extern Bool isvisible(Client *c);		/* returns True if client is visible */ | extern Bool isvisible(Client *c);		/* returns True if client is visible */ | ||||||
| extern void resizemaster(Arg *arg);		/* resizes the master percent with arg's index value */ | extern void resizemaster(Arg *arg);		/* resizes the master percent with arg's index value */ | ||||||
| extern void restack(void);			/* restores z layers of all clients */ | extern void restack(void);			/* restores z layers of all clients */ | ||||||
|  | |||||||
							
								
								
									
										3
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								main.c
									
									
									
									
									
								
							| @ -20,7 +20,7 @@ | |||||||
| char stext[1024]; | char stext[1024]; | ||||||
| Bool *seltag; | Bool *seltag; | ||||||
| int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah; | int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah; | ||||||
| unsigned int master, ntags, numlockmask; | unsigned int master, nmaster, ntags, numlockmask; | ||||||
| Atom wmatom[WMLast], netatom[NetLast]; | Atom wmatom[WMLast], netatom[NetLast]; | ||||||
| Bool running = True; | Bool running = True; | ||||||
| Bool issel = True; | Bool issel = True; | ||||||
| @ -133,6 +133,7 @@ setup(void) { | |||||||
| 	sw = DisplayWidth(dpy, screen); | 	sw = DisplayWidth(dpy, screen); | ||||||
| 	sh = DisplayHeight(dpy, screen); | 	sh = DisplayHeight(dpy, screen); | ||||||
| 	master = MASTER; | 	master = MASTER; | ||||||
|  | 	nmaster = NMASTER; | ||||||
| 	/* bar */ | 	/* bar */ | ||||||
| 	bx = sx; | 	bx = sx; | ||||||
| 	by = sy; | 	by = sy; | ||||||
|  | |||||||
							
								
								
									
										51
									
								
								view.c
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								view.c
									
									
									
									
									
								
							| @ -69,12 +69,16 @@ dofloat(void) { | |||||||
| 
 | 
 | ||||||
| void | void | ||||||
| dotile(void) { | dotile(void) { | ||||||
| 	unsigned int i, n, mpw, th; | 	unsigned int i, n, mw, mh, tw, th; | ||||||
| 	Client *c; | 	Client *c; | ||||||
| 
 | 
 | ||||||
| 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) | 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) | ||||||
| 		n++; | 		n++; | ||||||
| 	mpw = (waw * master) / 1000; | 	/* window geoms */ | ||||||
|  | 	mw = (n > nmaster) ? (waw * master) / 1000 : waw; | ||||||
|  | 	mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1); | ||||||
|  | 	tw = waw - mw; | ||||||
|  | 	th = (n > nmaster) ? wah / (n - nmaster) : 0; | ||||||
| 
 | 
 | ||||||
| 	for(i = 0, c = clients; c; c = c->next) | 	for(i = 0, c = clients; c; c = c->next) | ||||||
| 		if(isvisible(c)) { | 		if(isvisible(c)) { | ||||||
| @ -85,20 +89,16 @@ dotile(void) { | |||||||
| 			c->ismax = False; | 			c->ismax = False; | ||||||
| 			c->x = wax; | 			c->x = wax; | ||||||
| 			c->y = way; | 			c->y = way; | ||||||
| 			if(n == 1) { /* only 1 window */ | 			if(i < nmaster) { | ||||||
| 				c->w = waw - 2 * BORDERPX; | 				c->y += i * mh; | ||||||
| 				c->h = wah - 2 * BORDERPX; | 				c->w = mw - 2 * BORDERPX; | ||||||
| 			} | 				c->h = mh - 2 * BORDERPX; | ||||||
| 			else if(i == 0) { /* master window */ |  | ||||||
| 				c->w = mpw - 2 * BORDERPX; |  | ||||||
| 				c->h = wah - 2 * BORDERPX; |  | ||||||
| 				th = wah / (n - 1); |  | ||||||
| 			} | 			} | ||||||
| 			else {  /* tile window */ | 			else {  /* tile window */ | ||||||
| 				c->x += mpw; | 				c->x += mw; | ||||||
| 				c->w = (waw - mpw) - 2 * BORDERPX; | 				c->w = tw - 2 * BORDERPX; | ||||||
| 				if(th > bh) { | 				if(th > bh) { | ||||||
| 					c->y += (i - 1) * th; | 					c->y += (i - nmaster) * th; | ||||||
| 					c->h = th - 2 * BORDERPX; | 					c->h = th - 2 * BORDERPX; | ||||||
| 				} | 				} | ||||||
| 				else /* fallback if th < bh */ | 				else /* fallback if th < bh */ | ||||||
| @ -147,6 +147,14 @@ focusprev(Arg *arg) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void | ||||||
|  | incnmaster(Arg *arg) { | ||||||
|  | 	if(nmaster + arg->i < 1) | ||||||
|  | 		return; | ||||||
|  | 	nmaster += arg->i; | ||||||
|  | 	arrange(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| Bool | Bool | ||||||
| isvisible(Client *c) { | isvisible(Client *c) { | ||||||
| 	unsigned int i; | 	unsigned int i; | ||||||
| @ -240,7 +248,7 @@ view(Arg *arg) { | |||||||
| 
 | 
 | ||||||
| void | void | ||||||
| zoom(Arg *arg) { | zoom(Arg *arg) { | ||||||
| 	unsigned int n; | 	unsigned int i, n; | ||||||
| 	Client *c; | 	Client *c; | ||||||
| 
 | 
 | ||||||
| 	if(!sel) | 	if(!sel) | ||||||
| @ -249,14 +257,19 @@ zoom(Arg *arg) { | |||||||
| 		togglemax(sel); | 		togglemax(sel); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	for(n = 0, c = clients; c; c = c->next) | 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) | ||||||
| 		if(isvisible(c) && !c->isfloat) |  | ||||||
| 		n++; | 		n++; | ||||||
| 	if(n < 2 || (arrange == dofloat)) | 	if(n <= nmaster || (arrange == dofloat)) | ||||||
| 		return; | 		return; | ||||||
| 	if((c = sel) == nexttiled(clients)) | 
 | ||||||
| 		if(!(c = nexttiled(c->next))) | 	for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c = nexttiled(c->next)) | ||||||
|  | 		i++; | ||||||
|  | 	if(c == sel && i < nmaster) | ||||||
|  | 		for(; c && i < nmaster; c = nexttiled(c->next)) | ||||||
|  | 			i++; | ||||||
|  | 	if(!c) | ||||||
| 		return; | 		return; | ||||||
|  | 
 | ||||||
| 	detach(c); | 	detach(c); | ||||||
| 	if(clients) | 	if(clients) | ||||||
| 		clients->prev = c; | 		clients->prev = c; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user