tadded MODKEY-{plus,minus} shortcuts (increasing/decreasing master clients) - d… | |
git clone git://src.adamsgaard.dk/dwm | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 06bae9dfb7902c97877f3493cf4b489ccf531089 | |
parent 0b80d1842d1c921a8a94c11fd9222dad9311cc97 | |
Author: Anselm R. Garbe <[email protected]> | |
Date: Fri, 5 Jan 2007 14:48:16 +0100 | |
added MODKEY-{plus,minus} shortcuts (increasing/decreasing master clients) | |
Diffstat: | |
M config.arg.h | 4 ++-- | |
M config.default.h | 2 ++ | |
M dwm.1 | 6 ++++++ | |
M view.c | 65 +++++++++++++++++++++++++----… | |
4 files changed, 62 insertions(+), 15 deletions(-) | |
--- | |
diff --git a/config.arg.h b/config.arg.h | |
t@@ -31,13 +31,13 @@ static Key key[] = { \ | |
{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u "… | |
" | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMF… | |
"-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe… | |
- { MODKEY, XK_d, incnmaster, … | |
{ MODKEY, XK_j, focusnext, … | |
{ MODKEY, XK_k, focusprev, … | |
{ MODKEY, XK_Return, zoom, … | |
{ MODKEY, XK_g, resizemaster, … | |
- { MODKEY, XK_i, incnmaster, … | |
{ MODKEY, XK_s, resizemaster, … | |
+ { MODKEY, XK_plus, incnmaster, { … | |
+ { MODKEY, XK_minus, incnmaster, {… | |
{ MODKEY|ShiftMask, XK_0, tag, … | |
{ MODKEY|ShiftMask, XK_1, tag, … | |
{ MODKEY|ShiftMask, XK_2, tag, … | |
diff --git a/config.default.h b/config.default.h | |
t@@ -31,6 +31,8 @@ static Key key[] = { \ | |
{ MODKEY, XK_Return, zoom, … | |
{ MODKEY, XK_g, resizemaster, … | |
{ MODKEY, XK_s, resizemaster, … | |
+ { MODKEY, XK_plus, incnmaster, { … | |
+ { MODKEY, XK_minus, incnmaster, {… | |
{ MODKEY|ShiftMask, XK_0, tag, … | |
{ MODKEY|ShiftMask, XK_1, tag, … | |
{ MODKEY|ShiftMask, XK_2, tag, … | |
diff --git a/dwm.1 b/dwm.1 | |
t@@ -70,6 +70,12 @@ Grow master area (tiling mode only). | |
.B Mod1-s | |
Shrink master area (tiling mode only). | |
.TP | |
+.B Mod1-plus | |
+Increase clients of master area (tiling mode only). | |
+.TP | |
+.B Mod1-minus | |
+Decrease clients of master area (tiling mode only). | |
+.TP | |
.B Mod1-Shift-[1..n] | |
Apply | |
.RB nth | |
diff --git a/view.c b/view.c | |
t@@ -11,6 +11,40 @@ nexttiled(Client *c) { | |
return c; | |
} | |
+static Bool | |
+ismaster(Client *c) { | |
+ Client *cl; | |
+ unsigned int i; | |
+ | |
+ for(cl = nexttiled(clients), i = 0; cl && cl != c; cl = nexttiled(cl->… | |
+ return i < nmaster; | |
+} | |
+ | |
+static void | |
+pop(Client *c) { | |
+ detach(c); | |
+ if(clients) | |
+ clients->prev = c; | |
+ c->next = clients; | |
+ clients = c; | |
+} | |
+ | |
+static void | |
+swap(Client *c1, Client *c2) { | |
+ Client tmp = *c1; | |
+ Client *cp = c1->prev; | |
+ Client *cn = c1->next; | |
+ | |
+ *c1 = *c2; | |
+ c1->prev = cp; | |
+ c1->next = cn; | |
+ cp = c2->prev; | |
+ cn = c2->next; | |
+ *c2 = tmp; | |
+ c2->prev = cp; | |
+ c2->next = cn; | |
+} | |
+ | |
static void | |
togglemax(Client *c) { | |
XEvent ev; | |
t@@ -34,6 +68,15 @@ togglemax(Client *c) { | |
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); | |
} | |
+static Client * | |
+topofstack() { | |
+ Client *c; | |
+ unsigned int i; | |
+ | |
+ for(c = nexttiled(clients), i = 0; c && i < nmaster; c = nexttiled(c->… | |
+ return (i < nmaster) ? NULL : c; | |
+} | |
+ | |
/* extern */ | |
void (*arrange)(void) = DEFMODE; | |
t@@ -248,7 +291,7 @@ view(Arg *arg) { | |
void | |
zoom(Arg *arg) { | |
- unsigned int i, n; | |
+ unsigned int n; | |
Client *c; | |
if(!sel) | |
t@@ -262,19 +305,15 @@ zoom(Arg *arg) { | |
if(n <= nmaster || (arrange == dofloat)) | |
return; | |
- for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c =… | |
- i++; | |
- if(c == sel && i < nmaster) | |
- for(; c && i < nmaster; c = nexttiled(c->next)) | |
- i++; | |
- if(!c) | |
- return; | |
+ if(ismaster((c = sel))) { | |
+ if(!(c = topofstack())) | |
+ return; | |
+ swap(c, sel); | |
+ c = sel; | |
+ } | |
+ else | |
+ pop(c); | |
- detach(c); | |
- if(clients) | |
- clients->prev = c; | |
- c->next = clients; | |
- clients = c; | |
focus(c); | |
arrange(); | |
} |