summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-02-22 07:59:13 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-02-22 07:59:13 +0100
commit352cae4380713949d3800ebcda7aff3bb5ab9efc (patch)
treedd301143a6777dacb09b90d6d27d16aeb19056fc
parentjust ignore the FD_ISSET check in main.c of xfd, just call XPending (which do... (diff)
downloaddwm-352cae4380713949d3800ebcda7aff3bb5ab9efc.tar.gz
dwm-352cae4380713949d3800ebcda7aff3bb5ab9efc.zip
several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Diffstat (limited to '')
-rw-r--r--client.c44
-rw-r--r--config.arg.h67
-rw-r--r--config.default.h61
-rw-r--r--dwm.115
-rw-r--r--dwm.h30
-rw-r--r--event.c20
-rw-r--r--layout.c92
-rw-r--r--main.c2
-rw-r--r--tag.c28
-rw-r--r--util.c8
10 files changed, 184 insertions, 183 deletions
diff --git a/client.c b/client.c
index c962c39..3d9cd40 100644
--- a/client.c
+++ b/client.c
@@ -83,24 +83,6 @@ setclientstate(Client *c, long state) {
83 PropModeReplace, (unsigned char *)data, 2); 83 PropModeReplace, (unsigned char *)data, 2);
84} 84}
85 85
86static void
87togglemax(Client *c) {
88 XEvent ev;
89
90 if(c->isfixed)
91 return;
92 if((c->ismax = !c->ismax)) {
93 c->rx = c->x;
94 c->ry = c->y;
95 c->rw = c->w;
96 c->rh = c->h;
97 resize(c, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
98 }
99 else
100 resize(c, c->rx, c->ry, c->rw, c->rh, True);
101 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
102}
103
104static int 86static int
105xerrordummy(Display *dsply, XErrorEvent *ee) { 87xerrordummy(Display *dsply, XErrorEvent *ee) {
106 return 0; 88 return 0;
@@ -171,7 +153,7 @@ focus(Client *c) {
171} 153}
172 154
173void 155void
174killclient(Arg *arg) { 156killclient(Arg arg) {
175 if(!sel) 157 if(!sel)
176 return; 158 return;
177 if(isprotodel(sel)) 159 if(isprotodel(sel))
@@ -303,7 +285,7 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
303} 285}
304 286
305void 287void
306toggleversatile(Arg *arg) { 288toggleversatile(Arg arg) {
307 if(!sel || lt->arrange == versatile) 289 if(!sel || lt->arrange == versatile)
308 return; 290 return;
309 sel->isversatile = !sel->isversatile; 291 sel->isversatile = !sel->isversatile;
@@ -402,25 +384,3 @@ unmanage(Client *c) {
402 XUngrabServer(dpy); 384 XUngrabServer(dpy);
403 lt->arrange(); 385 lt->arrange();
404} 386}
405
406void
407zoom(Arg *arg) {
408 unsigned int n;
409 Client *c;
410
411 if(!sel)
412 return;
413 if(sel->isversatile || (lt->arrange == versatile)) {
414 togglemax(sel);
415 return;
416 }
417 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
418 n++;
419 if((c = sel) == nexttiled(clients))
420 if(!(c = nexttiled(c->next)))
421 return;
422 detach(c);
423 attach(c);
424 focus(c);
425 lt->arrange();
426}
diff --git a/config.arg.h b/config.arg.h
index a887430..afbc4d1 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -14,7 +14,6 @@
14#define TOPBAR True /* False */ 14#define TOPBAR True /* False */
15 15
16/* behavior */ 16/* behavior */
17#define SNAP 40 /* pixel */
18#define TAGS \ 17#define TAGS \
19const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL }; 18const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
20#define RULES \ 19#define RULES \
@@ -33,27 +32,41 @@ static Layout layout[] = { \
33 { "[]=", tile }, /* first entry is default */ \ 32 { "[]=", tile }, /* first entry is default */ \
34 { "><>", versatile }, \ 33 { "><>", versatile }, \
35}; 34};
36#define MASTER 600 /* per thousand */ 35#define MASTERWIDTH 600 /* master width per thousand */
37#define NMASTER 1 /* clients in master area */ 36#define NMASTER 1 /* clients in master area */
37#define SNAP 40 /* versatile snap pixel */
38 38
39/* key definitions */ 39/* key definitions */
40#define MODKEY Mod1Mask 40#define MODKEY Mod1Mask
41#define KEYS \ 41#define KEYS \
42static Key key[] = { \ 42static Key key[] = { \
43 /* modifier key function argument */ \ 43 /* modifier key function argument */ \
44 { MODKEY|ShiftMask, XK_Return, spawn, \ 44 { MODKEY, XK_Return, zoom, { 0 } }, \
45 { .cmd = "exec urxvtcd -tr -bg '#292929' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" } }, \ 45 { MODKEY, XK_space, setlayout, { .i = -1 } }, \
46 { MODKEY, XK_0, view, { .i = -1 } }, \
47 { MODKEY, XK_1, view, { .i = 0 } }, \
48 { MODKEY, XK_2, view, { .i = 1 } }, \
49 { MODKEY, XK_3, view, { .i = 2 } }, \
50 { MODKEY, XK_4, view, { .i = 3 } }, \
51 { MODKEY, XK_5, view, { .i = 4 } }, \
52 { MODKEY, XK_6, view, { .i = 5 } }, \
53 { MODKEY, XK_7, view, { .i = 6 } }, \
54 { MODKEY, XK_8, view, { .i = 7 } }, \
55 { MODKEY, XK_9, view, { .i = 8 } }, \
56 { MODKEY, XK_d, incnmaster, { .i = -1 } }, \
57 { MODKEY, XK_h, incmasterw, { .i = -15 } }, \
58 { MODKEY, XK_i, incnmaster, { .i = 1 } }, \
59 { MODKEY, XK_j, focusnext, { 0 } }, \
60 { MODKEY, XK_k, focusprev, { 0 } }, \
61 { MODKEY, XK_l, incmasterw, { .i = 15 } }, \
62 { MODKEY, XK_m, togglemax, { 0 } }, \
46 { MODKEY, XK_p, spawn, \ 63 { MODKEY, XK_p, spawn, \
47 { .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \ 64 { .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
48 " | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \ 65 " | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \
49 "-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \ 66 "-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \
50 { MODKEY, XK_j, focusnext, { 0 } }, \ 67 { MODKEY|ShiftMask, XK_Return, spawn, \
51 { MODKEY, XK_k, focusprev, { 0 } }, \ 68 { .cmd = "exec urxvtcd -tr -bg '#292929' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" } }, \
52 { MODKEY, XK_Return, zoom, { 0 } }, \ 69 { MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \
53 { MODKEY, XK_g, resizemaster, { .i = 15 } }, \
54 { MODKEY, XK_s, resizemaster, { .i = -15 } }, \
55 { MODKEY, XK_i, incnmaster, { .i = 1 } }, \
56 { MODKEY, XK_d, incnmaster, { .i = -1 } }, \
57 { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \ 70 { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
58 { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ 71 { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
59 { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \ 72 { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
@@ -64,28 +77,8 @@ static Key key[] = { \
64 { MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \ 77 { MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \
65 { MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \ 78 { MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \
66 { MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \ 79 { MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \
67 { MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
68 { MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
69 { MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
70 { MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
71 { MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
72 { MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
73 { MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
74 { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
75 { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
76 { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ 80 { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
77 { MODKEY, XK_space, setlayout, { .i = -1 } }, \ 81 { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
78 { MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \
79 { MODKEY, XK_0, view, { .i = -1 } }, \
80 { MODKEY, XK_1, view, { .i = 0 } }, \
81 { MODKEY, XK_2, view, { .i = 1 } }, \
82 { MODKEY, XK_3, view, { .i = 2 } }, \
83 { MODKEY, XK_4, view, { .i = 3 } }, \
84 { MODKEY, XK_5, view, { .i = 4 } }, \
85 { MODKEY, XK_6, view, { .i = 5 } }, \
86 { MODKEY, XK_7, view, { .i = 6 } }, \
87 { MODKEY, XK_8, view, { .i = 7 } }, \
88 { MODKEY, XK_9, view, { .i = 8 } }, \
89 { MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \ 82 { MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
90 { MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \ 83 { MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
91 { MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \ 84 { MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
@@ -95,5 +88,13 @@ static Key key[] = { \
95 { MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \ 88 { MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \
96 { MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \ 89 { MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \
97 { MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \ 90 { MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \
98 { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ 91 { MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
92 { MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
93 { MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
94 { MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
95 { MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
96 { MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
97 { MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
98 { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
99 { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
99}; 100};
diff --git a/config.default.h b/config.default.h
index eb6933b..ebe91e9 100644
--- a/config.default.h
+++ b/config.default.h
@@ -14,7 +14,6 @@
14#define TOPBAR True /* False */ 14#define TOPBAR True /* False */
15 15
16/* behavior */ 16/* behavior */
17#define SNAP 20 /* pixel */
18#define TAGS \ 17#define TAGS \
19const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL }; 18const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
20/* Query class:instance:title for regex matching info with following command: 19/* Query class:instance:title for regex matching info with following command:
@@ -34,22 +33,36 @@ static Layout layout[] = { \
34 { "[]=", tile }, /* first entry is default */ \ 33 { "[]=", tile }, /* first entry is default */ \
35 { "><>", versatile }, \ 34 { "><>", versatile }, \
36}; 35};
37#define MASTER 600 /* per thousand */ 36#define MASTERWIDTH 600 /* master width per thousand */
38#define NMASTER 1 /* clients in master area */ 37#define NMASTER 1 /* clients in master area */
38#define SNAP 20 /* versatile snap pixel */
39 39
40/* key definitions */ 40/* key definitions */
41#define MODKEY Mod1Mask 41#define MODKEY Mod1Mask
42#define KEYS \ 42#define KEYS \
43static Key key[] = { \ 43static Key key[] = { \
44 /* modifier key function argument */ \ 44 /* modifier key function argument */ \
45 { MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \
46 { MODKEY, XK_Tab, focusnext, { 0 } }, \
47 { MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
48 { MODKEY, XK_Return, zoom, { 0 } }, \ 45 { MODKEY, XK_Return, zoom, { 0 } }, \
49 { MODKEY, XK_g, resizemaster, { .i = 15 } }, \ 46 { MODKEY, XK_space, setlayout, { .i = -1 } }, \
50 { MODKEY, XK_s, resizemaster, { .i = -15 } }, \ 47 { MODKEY, XK_0, view, { .i = -1 } }, \
51 { MODKEY, XK_i, incnmaster, { .i = 1 } }, \ 48 { MODKEY, XK_1, view, { .i = 0 } }, \
49 { MODKEY, XK_2, view, { .i = 1 } }, \
50 { MODKEY, XK_3, view, { .i = 2 } }, \
51 { MODKEY, XK_4, view, { .i = 3 } }, \
52 { MODKEY, XK_5, view, { .i = 4 } }, \
53 { MODKEY, XK_6, view, { .i = 5 } }, \
54 { MODKEY, XK_7, view, { .i = 6 } }, \
55 { MODKEY, XK_8, view, { .i = 7 } }, \
56 { MODKEY, XK_9, view, { .i = 8 } }, \
52 { MODKEY, XK_d, incnmaster, { .i = -1 } }, \ 57 { MODKEY, XK_d, incnmaster, { .i = -1 } }, \
58 { MODKEY, XK_h, incmasterw, { .i = -15 } }, \
59 { MODKEY, XK_i, incnmaster, { .i = 1 } }, \
60 { MODKEY, XK_j, focusnext, { 0 } }, \
61 { MODKEY, XK_k, focusprev, { 0 } }, \
62 { MODKEY, XK_l, incmasterw, { .i = 15 } }, \
63 { MODKEY, XK_m, togglemax, { 0 } }, \
64 { MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \
65 { MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \
53 { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \ 66 { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
54 { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ 67 { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
55 { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \ 68 { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
@@ -60,28 +73,8 @@ static Key key[] = { \
60 { MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \ 73 { MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \
61 { MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \ 74 { MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \
62 { MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \ 75 { MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \
63 { MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
64 { MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
65 { MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
66 { MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
67 { MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
68 { MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
69 { MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
70 { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
71 { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
72 { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ 76 { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
73 { MODKEY, XK_space, setlayout, { .i = -1 } }, \ 77 { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
74 { MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \
75 { MODKEY, XK_0, view, { .i = -1 } }, \
76 { MODKEY, XK_1, view, { .i = 0 } }, \
77 { MODKEY, XK_2, view, { .i = 1 } }, \
78 { MODKEY, XK_3, view, { .i = 2 } }, \
79 { MODKEY, XK_4, view, { .i = 3 } }, \
80 { MODKEY, XK_5, view, { .i = 4 } }, \
81 { MODKEY, XK_6, view, { .i = 5 } }, \
82 { MODKEY, XK_7, view, { .i = 6 } }, \
83 { MODKEY, XK_8, view, { .i = 7 } }, \
84 { MODKEY, XK_9, view, { .i = 8 } }, \
85 { MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \ 78 { MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
86 { MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \ 79 { MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
87 { MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \ 80 { MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
@@ -91,5 +84,13 @@ static Key key[] = { \
91 { MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \ 84 { MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \
92 { MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \ 85 { MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \
93 { MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \ 86 { MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \
94 { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ 87 { MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
88 { MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
89 { MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
90 { MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
91 { MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
92 { MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
93 { MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
94 { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
95 { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
95}; 96};
diff --git a/dwm.1 b/dwm.1
index cac0858..8d22a3d 100644
--- a/dwm.1
+++ b/dwm.1
@@ -60,19 +60,19 @@ click on a tag label adds/removes that tag to/from the focused window.
60Start 60Start
61.BR xterm (1). 61.BR xterm (1).
62.TP 62.TP
63.B Mod1-Tab 63.B Mod1-j
64Focus next window. 64Focus next window.
65.TP 65.TP
66.B Mod1-Shift-Tab 66.B Mod1-k
67Focus previous window. 67Focus previous window.
68.TP 68.TP
69.B Mod1-Return 69.B Mod1-Return
70Zooms/cycles current window to/from master area (tiling layout), toggles maximization of current window (versatile layout). 70Zooms/cycles current window to/from master area (tiling layout only).
71.TP 71.TP
72.B Mod1-g 72.B Mod1-l
73Grow master area (tiling layout only). 73Grow master area (tiling layout only).
74.TP 74.TP
75.B Mod1-s 75.B Mod1-h
76Shrink master area (tiling layout only). 76Shrink master area (tiling layout only).
77.TP 77.TP
78.B Mod1-i 78.B Mod1-i
@@ -81,6 +81,9 @@ Increase the number of windows in the master area (tiling layout only).
81.B Mod1-d 81.B Mod1-d
82Decrease the number of windows in the master area (tiling layout only). 82Decrease the number of windows in the master area (tiling layout only).
83.TP 83.TP
84.B Mod1-m
85Toggles maximization of current window (versatile layout only).
86.TP
84.B Mod1-Shift-[1..n] 87.B Mod1-Shift-[1..n]
85Apply 88Apply
86.RB nth 89.RB nth
@@ -124,7 +127,7 @@ Quit dwm.
124Move current window while dragging (versatile layout only). 127Move current window while dragging (versatile layout only).
125.TP 128.TP
126.B Mod1-Button2 129.B Mod1-Button2
127Zooms/cycles current window to/from master area (tiling layout), toggles maximization of current window (versatile layout). 130Zooms/cycles current window to/from master area (tiling layout only).
128.TP 131.TP
129.B Mod1-Button3 132.B Mod1-Button3
130Resize current window while dragging (versatile layout only). 133Resize current window while dragging (versatile layout only).
diff --git a/dwm.h b/dwm.h
index f74c17b..6fe9e15 100644
--- a/dwm.h
+++ b/dwm.h
@@ -90,7 +90,6 @@ extern char stext[256]; /* status text */
90extern int screen, sx, sy, sw, sh; /* screen geometry */ 90extern int screen, sx, sy, sw, sh; /* screen geometry */
91extern int wax, way, wah, waw; /* windowarea geometry */ 91extern int wax, way, wah, waw; /* windowarea geometry */
92extern unsigned int bh, blw; /* bar height, bar layout label width */ 92extern unsigned int bh, blw; /* bar height, bar layout label width */
93extern unsigned int master, nmaster; /* master percent, number of master clients */
94extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */ 93extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
95extern void (*handler[LASTEvent])(XEvent *); /* event handler */ 94extern void (*handler[LASTEvent])(XEvent *); /* event handler */
96extern Atom wmatom[WMLast], netatom[NetLast]; 95extern Atom wmatom[WMLast], netatom[NetLast];
@@ -105,15 +104,14 @@ extern Window root, barwin;
105/* client.c */ 104/* client.c */
106extern void configure(Client *c); /* send synthetic configure event */ 105extern void configure(Client *c); /* send synthetic configure event */
107extern void focus(Client *c); /* focus c, c may be NULL */ 106extern void focus(Client *c); /* focus c, c may be NULL */
108extern void killclient(Arg *arg); /* kill c nicely */ 107extern void killclient(Arg arg); /* kill c nicely */
109extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ 108extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
110extern void resize(Client *c, int x, int y, 109extern void resize(Client *c, int x, int y,
111 int w, int h, Bool sizehints); /* resize with given coordinates c*/ 110 int w, int h, Bool sizehints); /* resize with given coordinates c*/
112extern void toggleversatile(Arg *arg); /* toggles focused client between versatile/and non-versatile state */ 111extern void toggleversatile(Arg arg); /* toggles focused client between versatile/and non-versatile state */
113extern void updatesizehints(Client *c); /* update the size hint variables of c */ 112extern void updatesizehints(Client *c); /* update the size hint variables of c */
114extern void updatetitle(Client *c); /* update the name of c */ 113extern void updatetitle(Client *c); /* update the name of c */
115extern void unmanage(Client *c); /* destroy c */ 114extern void unmanage(Client *c); /* destroy c */
116extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */
117 115
118/* draw.c */ 116/* draw.c */
119extern void drawstatus(void); /* draw the bar */ 117extern void drawstatus(void); /* draw the bar */
@@ -125,18 +123,19 @@ extern unsigned int textw(const char *text); /* return the width of text in px*/
125extern void grabkeys(void); /* grab all keys defined in config.h */ 123extern void grabkeys(void); /* grab all keys defined in config.h */
126 124
127/* layout.c */ 125/* layout.c */
128extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ 126extern void focusnext(Arg arg); /* focuses next visible client, arg is ignored */
129extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ 127extern void focusprev(Arg arg); /* focuses previous visible client, arg is ignored */
130extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */ 128extern void incmasterw(Arg arg); /* increments the master width with arg's index value */
129extern void incnmaster(Arg arg); /* increments nmaster with arg's index value */
131extern void initlayouts(void); /* initialize layout array */ 130extern void initlayouts(void); /* initialize layout array */
132extern Client *nexttiled(Client *c); /* returns tiled successor of c */ 131extern Client *nexttiled(Client *c); /* returns tiled successor of c */
133extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */
134extern void restack(void); /* restores z layers of all clients */ 132extern void restack(void); /* restores z layers of all clients */
135extern void setlayout(Arg *arg); /* sets layout, -1 toggles */ 133extern void setlayout(Arg arg); /* sets layout, -1 toggles */
134extern void togglemax(Arg arg); /* toggles maximization of versatile client */
136extern void versatile(void); /* arranges all windows versatile */ 135extern void versatile(void); /* arranges all windows versatile */
137 136
138/* main.c */ 137/* main.c */
139extern void quit(Arg *arg); /* quit dwm nicely */ 138extern void quit(Arg arg); /* quit dwm nicely */
140extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ 139extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
141extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ 140extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
142 141
@@ -144,13 +143,14 @@ extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
144extern void compileregs(void); /* initialize regexps of rules defined in config.h */ 143extern void compileregs(void); /* initialize regexps of rules defined in config.h */
145extern Bool isvisible(Client *c); /* returns True if client is visible */ 144extern Bool isvisible(Client *c); /* returns True if client is visible */
146extern void settags(Client *c, Client *trans); /* sets tags of c */ 145extern void settags(Client *c, Client *trans); /* sets tags of c */
147extern void tag(Arg *arg); /* tags c with arg's index */ 146extern void tag(Arg arg); /* tags c with arg's index */
148extern void toggletag(Arg *arg); /* toggles c tags with arg's index */ 147extern void toggletag(Arg arg); /* toggles c tags with arg's index */
149extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */ 148extern void toggleview(Arg arg); /* toggles the tag with arg's index (in)visible */
150extern void view(Arg *arg); /* views the tag with arg's index */ 149extern void view(Arg arg); /* views the tag with arg's index */
150extern void zoom(Arg arg); /* zooms the focused client to master area, arg is ignored */
151 151
152/* util.c */ 152/* util.c */
153extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ 153extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
154extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ 154extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
155extern void spawn(Arg *arg); /* forks a new subprocess with arg's cmd */ 155extern void spawn(Arg arg); /* forks a new subprocess with arg's cmd */
156 156
diff --git a/event.c b/event.c
index 3086284..540aeb6 100644
--- a/event.c
+++ b/event.c
@@ -11,7 +11,7 @@
11typedef struct { 11typedef struct {
12 unsigned long mod; 12 unsigned long mod;
13 KeySym keysym; 13 KeySym keysym;
14 void (*func)(Arg *arg); 14 void (*func)(Arg arg);
15 Arg arg; 15 Arg arg;
16} Key; 16} Key;
17 17
@@ -124,15 +124,15 @@ buttonpress(XEvent *e) {
124 if(ev->x < x) { 124 if(ev->x < x) {
125 if(ev->button == Button1) { 125 if(ev->button == Button1) {
126 if(ev->state & MODKEY) 126 if(ev->state & MODKEY)
127 tag(&a); 127 tag(a);
128 else 128 else
129 view(&a); 129 view(a);
130 } 130 }
131 else if(ev->button == Button3) { 131 else if(ev->button == Button3) {
132 if(ev->state & MODKEY) 132 if(ev->state & MODKEY)
133 toggletag(&a); 133 toggletag(a);
134 else 134 else
135 toggleview(&a); 135 toggleview(a);
136 } 136 }
137 return; 137 return;
138 } 138 }
@@ -141,15 +141,15 @@ buttonpress(XEvent *e) {
141 switch(ev->button) { 141 switch(ev->button) {
142 case Button1: 142 case Button1:
143 a.i = -1; 143 a.i = -1;
144 setlayout(&a); 144 setlayout(a);
145 break; 145 break;
146 case Button4: 146 case Button4:
147 a.i = 1; 147 a.i = 1;
148 incnmaster(&a); 148 incnmaster(a);
149 break; 149 break;
150 case Button5: 150 case Button5:
151 a.i = -1; 151 a.i = -1;
152 incnmaster(&a); 152 incnmaster(a);
153 break; 153 break;
154 } 154 }
155 } 155 }
@@ -162,7 +162,7 @@ buttonpress(XEvent *e) {
162 movemouse(c); 162 movemouse(c);
163 } 163 }
164 else if(ev->button == Button2) 164 else if(ev->button == Button2)
165 zoom(NULL); 165 zoom(a);
166 else if(ev->button == Button3 166 else if(ev->button == Button3
167 && (lt->arrange == versatile || c->isversatile) && !c->isfixed) 167 && (lt->arrange == versatile || c->isversatile) && !c->isfixed)
168 { 168 {
@@ -261,7 +261,7 @@ keypress(XEvent *e) {
261 && CLEANMASK(key[i].mod) == CLEANMASK(ev->state)) 261 && CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
262 { 262 {
263 if(key[i].func) 263 if(key[i].func)
264 key[i].func(&key[i].arg); 264 key[i].func(key[i].arg);
265 } 265 }
266} 266}
267 267
diff --git a/layout.c b/layout.c
index e5f635c..6a65599 100644
--- a/layout.c
+++ b/layout.c
@@ -3,14 +3,14 @@
3 */ 3 */
4#include "dwm.h" 4#include "dwm.h"
5 5
6unsigned int master = MASTER;
7unsigned int nmaster = NMASTER;
8unsigned int blw = 0; 6unsigned int blw = 0;
9Layout *lt = NULL; 7Layout *lt = NULL;
10 8
11/* static */ 9/* static */
12 10
13static unsigned int nlayouts = 0; 11static unsigned int nlayouts = 0;
12static unsigned int masterw = MASTERWIDTH;
13static unsigned int nmaster = NMASTER;
14 14
15static void 15static void
16tile(void) { 16tile(void) {
@@ -21,7 +21,7 @@ tile(void) {
21 n++; 21 n++;
22 /* window geoms */ 22 /* window geoms */
23 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1); 23 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
24 mw = (n > nmaster) ? (waw * master) / 1000 : waw; 24 mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
25 th = (n > nmaster) ? wah / (n - nmaster) : 0; 25 th = (n > nmaster) ? wah / (n - nmaster) : 0;
26 tw = waw - mw; 26 tw = waw - mw;
27 27
@@ -69,7 +69,7 @@ LAYOUTS
69/* extern */ 69/* extern */
70 70
71void 71void
72focusnext(Arg *arg) { 72focusnext(Arg arg) {
73 Client *c; 73 Client *c;
74 74
75 if(!sel) 75 if(!sel)
@@ -84,7 +84,7 @@ focusnext(Arg *arg) {
84} 84}
85 85
86void 86void
87focusprev(Arg *arg) { 87focusprev(Arg arg) {
88 Client *c; 88 Client *c;
89 89
90 if(!sel) 90 if(!sel)
@@ -101,11 +101,26 @@ focusprev(Arg *arg) {
101} 101}
102 102
103void 103void
104incnmaster(Arg *arg) { 104incmasterw(Arg arg) {
105 if((lt->arrange != tile) || (nmaster + arg->i < 1) 105 if(lt->arrange != tile)
106 || (wah / (nmaster + arg->i) <= 2 * BORDERPX)) 106 return;
107 if(arg.i == 0)
108 masterw = MASTERWIDTH;
109 else {
110 if(waw * (masterw + arg.i) / 1000 >= waw - 2 * BORDERPX
111 || waw * (masterw + arg.i) / 1000 <= 2 * BORDERPX)
112 return;
113 masterw += arg.i;
114 }
115 lt->arrange();
116}
117
118void
119incnmaster(Arg arg) {
120 if((lt->arrange != tile) || (nmaster + arg.i < 1)
121 || (wah / (nmaster + arg.i) <= 2 * BORDERPX))
107 return; 122 return;
108 nmaster += arg->i; 123 nmaster += arg.i;
109 if(sel) 124 if(sel)
110 lt->arrange(); 125 lt->arrange();
111 else 126 else
@@ -132,21 +147,6 @@ nexttiled(Client *c) {
132} 147}
133 148
134void 149void
135resizemaster(Arg *arg) {
136 if(lt->arrange != tile)
137 return;
138 if(arg->i == 0)
139 master = MASTER;
140 else {
141 if(waw * (master + arg->i) / 1000 >= waw - 2 * BORDERPX
142 || waw * (master + arg->i) / 1000 <= 2 * BORDERPX)
143 return;
144 master += arg->i;
145 }
146 lt->arrange();
147}
148
149void
150restack(void) { 150restack(void) {
151 Client *c; 151 Client *c;
152 XEvent ev; 152 XEvent ev;
@@ -170,10 +170,10 @@ restack(void) {
170} 170}
171 171
172void 172void
173setlayout(Arg *arg) { 173setlayout(Arg arg) {
174 unsigned int i; 174 unsigned int i;
175 175
176 if(arg->i == -1) { 176 if(arg.i == -1) {
177 for(i = 0; i < nlayouts && lt != &layout[i]; i++); 177 for(i = 0; i < nlayouts && lt != &layout[i]; i++);
178 if(i == nlayouts - 1) 178 if(i == nlayouts - 1)
179 lt = &layout[0]; 179 lt = &layout[0];
@@ -181,9 +181,9 @@ setlayout(Arg *arg) {
181 lt = &layout[++i]; 181 lt = &layout[++i];
182 } 182 }
183 else { 183 else {
184 if(arg->i < 0 || arg->i >= nlayouts) 184 if(arg.i < 0 || arg.i >= nlayouts)
185 return; 185 return;
186 lt = &layout[arg->i]; 186 lt = &layout[arg.i];
187 } 187 }
188 if(sel) 188 if(sel)
189 lt->arrange(); 189 lt->arrange();
@@ -192,6 +192,24 @@ setlayout(Arg *arg) {
192} 192}
193 193
194void 194void
195togglemax(Arg arg) {
196 XEvent ev;
197
198 if(!sel || !sel->isversatile || sel->isfixed || lt->arrange != versatile)
199 return;
200 if((sel->ismax = !sel->ismax)) {
201 sel->rx = sel->x;
202 sel->ry = sel->y;
203 sel->rw = sel->w;
204 sel->rh = sel->h;
205 resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
206 }
207 else
208 resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
209 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
210}
211
212void
195versatile(void) { 213versatile(void) {
196 Client *c; 214 Client *c;
197 215
@@ -213,3 +231,21 @@ versatile(void) {
213 } 231 }
214 restack(); 232 restack();
215} 233}
234
235void
236zoom(Arg arg) {
237 unsigned int n;
238 Client *c;
239
240 if(!sel || lt->arrange != tile || sel->isversatile)
241 return;
242 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
243 n++;
244 if((c = sel) == nexttiled(clients))
245 if(!(c = nexttiled(c->next)))
246 return;
247 detach(c);
248 attach(c);
249 focus(c);
250 lt->arrange();
251}
diff --git a/main.c b/main.c
index c92f415..d06a1b3 100644
--- a/main.c
+++ b/main.c
@@ -236,7 +236,7 @@ sendevent(Window w, Atom a, long value) {
236} 236}
237 237
238void 238void
239quit(Arg *arg) { 239quit(Arg arg) {
240 readin = running = False; 240 readin = running = False;
241} 241}
242 242
diff --git a/tag.c b/tag.c
index c069dcc..d946309 100644
--- a/tag.c
+++ b/tag.c
@@ -102,49 +102,49 @@ settags(Client *c, Client *trans) {
102} 102}
103 103
104void 104void
105tag(Arg *arg) { 105tag(Arg arg) {
106 unsigned int i; 106 unsigned int i;
107 107
108 if(!sel) 108 if(!sel)
109 return; 109 return;
110 for(i = 0; i < ntags; i++) 110 for(i = 0; i < ntags; i++)
111 sel->tags[i] = (arg->i == -1) ? True : False; 111 sel->tags[i] = (arg.i == -1) ? True : False;
112 if(arg->i >= 0 && arg->i < ntags) 112 if(arg.i >= 0 && arg.i < ntags)
113 sel->tags[arg->i] = True; 113 sel->tags[arg.i] = True;
114 lt->arrange(); 114 lt->arrange();
115} 115}
116 116
117void 117void
118toggletag(Arg *arg) { 118toggletag(Arg arg) {
119 unsigned int i; 119 unsigned int i;
120 120
121 if(!sel) 121 if(!sel)
122 return; 122 return;
123 sel->tags[arg->i] = !sel->tags[arg->i]; 123 sel->tags[arg.i] = !sel->tags[arg.i];
124 for(i = 0; i < ntags && !sel->tags[i]; i++); 124 for(i = 0; i < ntags && !sel->tags[i]; i++);
125 if(i == ntags) 125 if(i == ntags)
126 sel->tags[arg->i] = True; 126 sel->tags[arg.i] = True;
127 lt->arrange(); 127 lt->arrange();
128} 128}
129 129
130void 130void
131toggleview(Arg *arg) { 131toggleview(Arg arg) {
132 unsigned int i; 132 unsigned int i;
133 133
134 seltag[arg->i] = !seltag[arg->i]; 134 seltag[arg.i] = !seltag[arg.i];
135 for(i = 0; i < ntags && !seltag[i]; i++); 135 for(i = 0; i < ntags && !seltag[i]; i++);
136 if(i == ntags) 136 if(i == ntags)
137 seltag[arg->i] = True; /* cannot toggle last view */ 137 seltag[arg.i] = True; /* cannot toggle last view */
138 lt->arrange(); 138 lt->arrange();
139} 139}
140 140
141void 141void
142view(Arg *arg) { 142view(Arg arg) {
143 unsigned int i; 143 unsigned int i;
144 144
145 for(i = 0; i < ntags; i++) 145 for(i = 0; i < ntags; i++)
146 seltag[i] = (arg->i == -1) ? True : False; 146 seltag[i] = (arg.i == -1) ? True : False;
147 if(arg->i >= 0 && arg->i < ntags) 147 if(arg.i >= 0 && arg.i < ntags)
148 seltag[arg->i] = True; 148 seltag[arg.i] = True;
149 lt->arrange(); 149 lt->arrange();
150} 150}
diff --git a/util.c b/util.c
index 8b36a3f..b786480 100644
--- a/util.c
+++ b/util.c
@@ -30,12 +30,12 @@ eprint(const char *errstr, ...) {
30} 30}
31 31
32void 32void
33spawn(Arg *arg) { 33spawn(Arg arg) {
34 static char *shell = NULL; 34 static char *shell = NULL;
35 35
36 if(!shell && !(shell = getenv("SHELL"))) 36 if(!shell && !(shell = getenv("SHELL")))
37 shell = "/bin/sh"; 37 shell = "/bin/sh";
38 if(!arg->cmd) 38 if(!arg.cmd)
39 return; 39 return;
40 /* The double-fork construct avoids zombie processes and keeps the code 40 /* The double-fork construct avoids zombie processes and keeps the code
41 * clean from stupid signal handlers. */ 41 * clean from stupid signal handlers. */
@@ -44,8 +44,8 @@ spawn(Arg *arg) {
44 if(dpy) 44 if(dpy)
45 close(ConnectionNumber(dpy)); 45 close(ConnectionNumber(dpy));
46 setsid(); 46 setsid();
47 execl(shell, shell, "-c", arg->cmd, (char *)NULL); 47 execl(shell, shell, "-c", arg.cmd, (char *)NULL);
48 fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg->cmd); 48 fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg.cmd);
49 perror(" failed"); 49 perror(" failed");
50 } 50 }
51 exit(0); 51 exit(0);