summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-01-05 14:48:16 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-01-05 14:48:16 +0100
commit06bae9dfb7902c97877f3493cf4b489ccf531089 (patch)
tree41e684607936b951f00dab79e1a2cb7c0cefe2be
parentexperimental version which allows master clients being increased/decreased (diff)
downloaddwm-06bae9dfb7902c97877f3493cf4b489ccf531089.tar.gz
dwm-06bae9dfb7902c97877f3493cf4b489ccf531089.zip
added MODKEY-{plus,minus} shortcuts (increasing/decreasing master clients)
-rw-r--r--config.arg.h4
-rw-r--r--config.default.h2
-rw-r--r--dwm.16
-rw-r--r--view.c65
4 files changed, 62 insertions, 15 deletions
diff --git a/config.arg.h b/config.arg.h
index d889d96..5167fea 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -31,13 +31,13 @@ static Key key[] = { \
31 { .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \ 31 { .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
32 " | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \ 32 " | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \
33 "-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \ 33 "-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \
34 { MODKEY, XK_d, incnmaster, { .i = -1 } }, \
35 { MODKEY, XK_j, focusnext, { 0 } }, \ 34 { MODKEY, XK_j, focusnext, { 0 } }, \
36 { MODKEY, XK_k, focusprev, { 0 } }, \ 35 { MODKEY, XK_k, focusprev, { 0 } }, \
37 { MODKEY, XK_Return, zoom, { 0 } }, \ 36 { MODKEY, XK_Return, zoom, { 0 } }, \
38 { MODKEY, XK_g, resizemaster, { .i = 15 } }, \ 37 { MODKEY, XK_g, resizemaster, { .i = 15 } }, \
39 { MODKEY, XK_i, incnmaster, { .i = 1 } }, \
40 { MODKEY, XK_s, resizemaster, { .i = -15 } }, \ 38 { MODKEY, XK_s, resizemaster, { .i = -15 } }, \
39 { MODKEY, XK_plus, incnmaster, { .i = 1 } }, \
40 { MODKEY, XK_minus, incnmaster, { .i = -1 } }, \
41 { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \ 41 { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
42 { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ 42 { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
43 { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \ 43 { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
diff --git a/config.default.h b/config.default.h
index 5b08f93..2015177 100644
--- a/config.default.h
+++ b/config.default.h
@@ -31,6 +31,8 @@ static Key key[] = { \
31 { MODKEY, XK_Return, zoom, { 0 } }, \ 31 { MODKEY, XK_Return, zoom, { 0 } }, \
32 { MODKEY, XK_g, resizemaster, { .i = 15 } }, \ 32 { MODKEY, XK_g, resizemaster, { .i = 15 } }, \
33 { MODKEY, XK_s, resizemaster, { .i = -15 } }, \ 33 { MODKEY, XK_s, resizemaster, { .i = -15 } }, \
34 { MODKEY, XK_plus, incnmaster, { .i = 1 } }, \
35 { MODKEY, XK_minus, incnmaster, { .i = -1 } }, \
34 { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \ 36 { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
35 { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ 37 { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
36 { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \ 38 { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
diff --git a/dwm.1 b/dwm.1
index 6eead84..8742fa8 100644
--- a/dwm.1
+++ b/dwm.1
@@ -70,6 +70,12 @@ Grow master area (tiling mode only).
70.B Mod1-s 70.B Mod1-s
71Shrink master area (tiling mode only). 71Shrink master area (tiling mode only).
72.TP 72.TP
73.B Mod1-plus
74Increase clients of master area (tiling mode only).
75.TP
76.B Mod1-minus
77Decrease clients of master area (tiling mode only).
78.TP
73.B Mod1-Shift-[1..n] 79.B Mod1-Shift-[1..n]
74Apply 80Apply
75.RB nth 81.RB nth
diff --git a/view.c b/view.c
index 1ac3141..2143d70 100644
--- a/view.c
+++ b/view.c
@@ -11,6 +11,40 @@ nexttiled(Client *c) {
11 return c; 11 return c;
12} 12}
13 13
14static Bool
15ismaster(Client *c) {
16 Client *cl;
17 unsigned int i;
18
19 for(cl = nexttiled(clients), i = 0; cl && cl != c; cl = nexttiled(cl->next), i++);
20 return i < nmaster;
21}
22
23static void
24pop(Client *c) {
25 detach(c);
26 if(clients)
27 clients->prev = c;
28 c->next = clients;
29 clients = c;
30}
31
32static void
33swap(Client *c1, Client *c2) {
34 Client tmp = *c1;
35 Client *cp = c1->prev;
36 Client *cn = c1->next;
37
38 *c1 = *c2;
39 c1->prev = cp;
40 c1->next = cn;
41 cp = c2->prev;
42 cn = c2->next;
43 *c2 = tmp;
44 c2->prev = cp;
45 c2->next = cn;
46}
47
14static void 48static void
15togglemax(Client *c) { 49togglemax(Client *c) {
16 XEvent ev; 50 XEvent ev;
@@ -34,6 +68,15 @@ togglemax(Client *c) {
34 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 68 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
35} 69}
36 70
71static Client *
72topofstack() {
73 Client *c;
74 unsigned int i;
75
76 for(c = nexttiled(clients), i = 0; c && i < nmaster; c = nexttiled(c->next), i++);
77 return (i < nmaster) ? NULL : c;
78}
79
37/* extern */ 80/* extern */
38 81
39void (*arrange)(void) = DEFMODE; 82void (*arrange)(void) = DEFMODE;
@@ -248,7 +291,7 @@ view(Arg *arg) {
248 291
249void 292void
250zoom(Arg *arg) { 293zoom(Arg *arg) {
251 unsigned int i, n; 294 unsigned int n;
252 Client *c; 295 Client *c;
253 296
254 if(!sel) 297 if(!sel)
@@ -262,19 +305,15 @@ zoom(Arg *arg) {
262 if(n <= nmaster || (arrange == dofloat)) 305 if(n <= nmaster || (arrange == dofloat))
263 return; 306 return;
264 307
265 for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c = nexttiled(c->next)) 308 if(ismaster((c = sel))) {
266 i++; 309 if(!(c = topofstack()))
267 if(c == sel && i < nmaster) 310 return;
268 for(; c && i < nmaster; c = nexttiled(c->next)) 311 swap(c, sel);
269 i++; 312 c = sel;
270 if(!c) 313 }
271 return; 314 else
315 pop(c);
272 316
273 detach(c);
274 if(clients)
275 clients->prev = c;
276 c->next = clients;
277 clients = c;
278 focus(c); 317 focus(c);
279 arrange(); 318 arrange();
280} 319}