aewl

changeset 651:b9f4efd21473

added MODKEY-{plus,minus} shortcuts (increasing/decreasing master clients)
author Anselm R. Garbe <arg@suckless.org>
date Fri, 05 Jan 2007 14:48:16 +0100
parents f3b8c71a69d4
children 98ce3aeb9df0
files config.arg.h config.default.h dwm.1 view.c
diffstat 4 files changed, 62 insertions(+), 15 deletions(-) [+]
line diff
     1.1 --- a/config.arg.h	Fri Jan 05 12:50:39 2007 +0100
     1.2 +++ b/config.arg.h	Fri Jan 05 14:48:16 2007 +0100
     1.3 @@ -31,13 +31,13 @@
     1.4  		{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
     1.5  			" | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \
     1.6  			"-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \
     1.7 -	{ MODKEY,			XK_d,		incnmaster,	{ .i = -1 } }, \
     1.8  	{ MODKEY,			XK_j,		focusnext,	{ 0 } }, \
     1.9  	{ MODKEY,			XK_k,		focusprev,	{ 0 } }, \
    1.10  	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \
    1.11  	{ MODKEY,			XK_g,		resizemaster,	{ .i = 15 } }, \
    1.12 -	{ MODKEY,			XK_i,		incnmaster,	{ .i = 1 } }, \
    1.13  	{ MODKEY,			XK_s,		resizemaster,	{ .i = -15 } }, \
    1.14 +	{ MODKEY,			XK_plus,	incnmaster,	{ .i = 1 } }, \
    1.15 +	{ MODKEY,			XK_minus,	incnmaster,	{ .i = -1 } }, \
    1.16  	{ MODKEY|ShiftMask,		XK_0,		tag,		{ .i = -1 } }, \
    1.17  	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \
    1.18  	{ MODKEY|ShiftMask,		XK_2,		tag,		{ .i = 1 } }, \
     2.1 --- a/config.default.h	Fri Jan 05 12:50:39 2007 +0100
     2.2 +++ b/config.default.h	Fri Jan 05 14:48:16 2007 +0100
     2.3 @@ -31,6 +31,8 @@
     2.4  	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \
     2.5  	{ MODKEY,			XK_g,		resizemaster,	{ .i = 15 } }, \
     2.6  	{ MODKEY,			XK_s,		resizemaster,	{ .i = -15 } }, \
     2.7 +	{ MODKEY,			XK_plus,	incnmaster,	{ .i = 1 } }, \
     2.8 +	{ MODKEY,			XK_minus,	incnmaster,	{ .i = -1 } }, \
     2.9  	{ MODKEY|ShiftMask,		XK_0,		tag,		{ .i = -1 } }, \
    2.10  	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \
    2.11  	{ MODKEY|ShiftMask,		XK_2,		tag,		{ .i = 1 } }, \
     3.1 --- a/dwm.1	Fri Jan 05 12:50:39 2007 +0100
     3.2 +++ b/dwm.1	Fri Jan 05 14:48:16 2007 +0100
     3.3 @@ -70,6 +70,12 @@
     3.4  .B Mod1-s
     3.5  Shrink master area (tiling mode only).
     3.6  .TP
     3.7 +.B Mod1-plus
     3.8 +Increase clients of master area (tiling mode only).
     3.9 +.TP
    3.10 +.B Mod1-minus
    3.11 +Decrease clients of master area (tiling mode only).
    3.12 +.TP
    3.13  .B Mod1-Shift-[1..n]
    3.14  Apply
    3.15  .RB nth
     4.1 --- a/view.c	Fri Jan 05 12:50:39 2007 +0100
     4.2 +++ b/view.c	Fri Jan 05 14:48:16 2007 +0100
     4.3 @@ -11,6 +11,40 @@
     4.4  	return c;
     4.5  }
     4.6  
     4.7 +static Bool
     4.8 +ismaster(Client *c) {
     4.9 +	Client *cl;
    4.10 +	unsigned int i;
    4.11 +
    4.12 +	for(cl = nexttiled(clients), i = 0; cl && cl != c; cl = nexttiled(cl->next), i++);
    4.13 +	return i < nmaster;
    4.14 +}
    4.15 +
    4.16 +static void
    4.17 +pop(Client *c) {
    4.18 +	detach(c);
    4.19 +	if(clients)
    4.20 +		clients->prev = c;
    4.21 +	c->next = clients;
    4.22 +	clients = c;
    4.23 +}
    4.24 +
    4.25 +static void
    4.26 +swap(Client *c1, Client *c2) {
    4.27 +	Client tmp = *c1;
    4.28 +	Client *cp = c1->prev;
    4.29 +	Client *cn = c1->next;
    4.30 +
    4.31 +	*c1 = *c2;
    4.32 +	c1->prev = cp;
    4.33 +	c1->next = cn;
    4.34 +	cp = c2->prev;
    4.35 +	cn = c2->next;
    4.36 +	*c2 = tmp;
    4.37 +	c2->prev = cp;
    4.38 +	c2->next = cn;
    4.39 +}
    4.40 +
    4.41  static void
    4.42  togglemax(Client *c) {
    4.43  	XEvent ev;
    4.44 @@ -34,6 +68,15 @@
    4.45  	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
    4.46  }
    4.47  
    4.48 +static Client *
    4.49 +topofstack() {
    4.50 +	Client *c;
    4.51 +	unsigned int i;
    4.52 +
    4.53 +	for(c = nexttiled(clients), i = 0; c && i < nmaster; c = nexttiled(c->next), i++);
    4.54 +	return (i < nmaster) ? NULL : c;
    4.55 +}
    4.56 +
    4.57  /* extern */
    4.58  
    4.59  void (*arrange)(void) = DEFMODE;
    4.60 @@ -248,7 +291,7 @@
    4.61  
    4.62  void
    4.63  zoom(Arg *arg) {
    4.64 -	unsigned int i, n;
    4.65 +	unsigned int n;
    4.66  	Client *c;
    4.67  
    4.68  	if(!sel)
    4.69 @@ -262,19 +305,15 @@
    4.70  	if(n <= nmaster || (arrange == dofloat))
    4.71  		return;
    4.72  
    4.73 -	for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c = nexttiled(c->next))
    4.74 -		i++;
    4.75 -	if(c == sel && i < nmaster)
    4.76 -		for(; c && i < nmaster; c = nexttiled(c->next))
    4.77 -			i++;
    4.78 -	if(!c)
    4.79 -		return;
    4.80 +	if(ismaster((c = sel))) {
    4.81 +		if(!(c = topofstack()))
    4.82 +			return;
    4.83 +		swap(c, sel);
    4.84 +		c = sel;
    4.85 +	}
    4.86 +	else
    4.87 +		pop(c);
    4.88  
    4.89 -	detach(c);
    4.90 -	if(clients)
    4.91 -		clients->prev = c;
    4.92 -	c->next = clients;
    4.93 -	clients = c;
    4.94  	focus(c);
    4.95  	arrange();
    4.96  }