summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-02-22 11:42:08 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-02-22 11:42:08 +0100
commit2c477cf66147d369ae8ff17acdce743c6811ee6a (patch)
tree121a031caf30be9f6931e37e26cf2469c8c7acfa
parentre-added xterm to config.default.h (diff)
downloaddwm-2c477cf66147d369ae8ff17acdce743c6811ee6a.tar.gz
dwm-2c477cf66147d369ae8ff17acdce743c6811ee6a.zip
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
-rw-r--r--client.c4
-rw-r--r--config.arg.h108
-rw-r--r--config.default.h102
-rw-r--r--dwm.h35
-rw-r--r--event.c28
-rw-r--r--layout.c38
-rw-r--r--main.c2
-rw-r--r--tag.c50
-rw-r--r--util.c8
9 files changed, 190 insertions, 185 deletions
diff --git a/client.c b/client.c
index 3d9cd40..2e443c2 100644
--- a/client.c
+++ b/client.c
@@ -153,7 +153,7 @@ focus(Client *c) {
153} 153}
154 154
155void 155void
156killclient(Arg arg) { 156killclient(const char *arg) {
157 if(!sel) 157 if(!sel)
158 return; 158 return;
159 if(isprotodel(sel)) 159 if(isprotodel(sel))
@@ -285,7 +285,7 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
285} 285}
286 286
287void 287void
288toggleversatile(Arg arg) { 288toggleversatile(const char *arg) {
289 if(!sel || lt->arrange == versatile) 289 if(!sel || lt->arrange == versatile)
290 return; 290 return;
291 sel->isversatile = !sel->isversatile; 291 sel->isversatile = !sel->isversatile;
diff --git a/config.arg.h b/config.arg.h
index 3cb4158..f137212 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -42,59 +42,59 @@ static Layout layout[] = { \
42static Key key[] = { \ 42static Key key[] = { \
43 /* modifier key function argument */ \ 43 /* modifier key function argument */ \
44 { MODKEY, XK_p, spawn, \ 44 { MODKEY, XK_p, spawn, \
45 { .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \ 45 "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
46 " | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \ 46 " | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \
47 "-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \ 47 "-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" }, \
48 { MODKEY|ShiftMask, XK_Return, spawn, \ 48 { MODKEY|ShiftMask, XK_Return, spawn, \
49 { .cmd = "exec urxvtcd -tr -bg '#292929' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" } }, \ 49 "exec urxvtcd -tr -bg '#292929' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" }, \
50 { MODKEY, XK_space, setlayout, { .i = -1 } }, \ 50 { MODKEY, XK_space, setlayout, NULL }, \
51 { MODKEY, XK_d, incnmaster, { .i = -1 } }, \ 51 { MODKEY, XK_d, incnmaster, "-1" }, \
52 { MODKEY, XK_i, incnmaster, { .i = 1 } }, \ 52 { MODKEY, XK_i, incnmaster, "1" }, \
53 { MODKEY, XK_h, incmasterw, { .i = -15 } }, \ 53 { MODKEY, XK_h, incmasterw, "-15" }, \
54 { MODKEY, XK_l, incmasterw, { .i = 15 } }, \ 54 { MODKEY, XK_l, incmasterw, "15" }, \
55 { MODKEY, XK_j, focusnext, { 0 } }, \ 55 { MODKEY, XK_j, focusnext, NULL }, \
56 { MODKEY, XK_k, focusprev, { 0 } }, \ 56 { MODKEY, XK_k, focusprev, NULL }, \
57 { MODKEY, XK_m, togglemax, { 0 } }, \ 57 { MODKEY, XK_m, togglemax, NULL }, \
58 { MODKEY, XK_Return, zoom, { 0 } }, \ 58 { MODKEY, XK_Return, zoom, NULL }, \
59 { MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \ 59 { MODKEY|ShiftMask, XK_space, toggleversatile,NULL }, \
60 { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ 60 { MODKEY|ShiftMask, XK_c, killclient, NULL }, \
61 { MODKEY, XK_0, view, { .i = -1 } }, \ 61 { MODKEY, XK_0, view, NULL }, \
62 { MODKEY, XK_1, view, { .i = 0 } }, \ 62 { MODKEY, XK_1, view, "0" }, \
63 { MODKEY, XK_2, view, { .i = 1 } }, \ 63 { MODKEY, XK_2, view, "1" }, \
64 { MODKEY, XK_3, view, { .i = 2 } }, \ 64 { MODKEY, XK_3, view, "2" }, \
65 { MODKEY, XK_4, view, { .i = 3 } }, \ 65 { MODKEY, XK_4, view, "3" }, \
66 { MODKEY, XK_5, view, { .i = 4 } }, \ 66 { MODKEY, XK_5, view, "4" }, \
67 { MODKEY, XK_6, view, { .i = 5 } }, \ 67 { MODKEY, XK_6, view, "5" }, \
68 { MODKEY, XK_7, view, { .i = 6 } }, \ 68 { MODKEY, XK_7, view, "6" }, \
69 { MODKEY, XK_8, view, { .i = 7 } }, \ 69 { MODKEY, XK_8, view, "7" }, \
70 { MODKEY, XK_9, view, { .i = 8 } }, \ 70 { MODKEY, XK_9, view, "8" }, \
71 { MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \ 71 { MODKEY|ControlMask, XK_1, toggleview, "0" }, \
72 { MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \ 72 { MODKEY|ControlMask, XK_2, toggleview, "1" }, \
73 { MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \ 73 { MODKEY|ControlMask, XK_3, toggleview, "2" }, \
74 { MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \ 74 { MODKEY|ControlMask, XK_4, toggleview, "3" }, \
75 { MODKEY|ControlMask, XK_5, toggleview, { .i = 4 } }, \ 75 { MODKEY|ControlMask, XK_5, toggleview, "4" }, \
76 { MODKEY|ControlMask, XK_6, toggleview, { .i = 5 } }, \ 76 { MODKEY|ControlMask, XK_6, toggleview, "5" }, \
77 { MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \ 77 { MODKEY|ControlMask, XK_7, toggleview, "6" }, \
78 { MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \ 78 { MODKEY|ControlMask, XK_8, toggleview, "7" }, \
79 { MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \ 79 { MODKEY|ControlMask, XK_9, toggleview, "8" }, \
80 { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \ 80 { MODKEY|ShiftMask, XK_0, tag, NULL }, \
81 { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ 81 { MODKEY|ShiftMask, XK_1, tag, "0" }, \
82 { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \ 82 { MODKEY|ShiftMask, XK_2, tag, "1" }, \
83 { MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \ 83 { MODKEY|ShiftMask, XK_3, tag, "2" }, \
84 { MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \ 84 { MODKEY|ShiftMask, XK_4, tag, "3" }, \
85 { MODKEY|ShiftMask, XK_5, tag, { .i = 4 } }, \ 85 { MODKEY|ShiftMask, XK_5, tag, "4" }, \
86 { MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \ 86 { MODKEY|ShiftMask, XK_6, tag, "5" }, \
87 { MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \ 87 { MODKEY|ShiftMask, XK_7, tag, "6" }, \
88 { MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \ 88 { MODKEY|ShiftMask, XK_8, tag, "7" }, \
89 { MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \ 89 { MODKEY|ShiftMask, XK_9, tag, "8" }, \
90 { MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \ 90 { MODKEY|ControlMask|ShiftMask, XK_1, toggletag, "0" }, \
91 { MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \ 91 { MODKEY|ControlMask|ShiftMask, XK_2, toggletag, "1" }, \
92 { MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \ 92 { MODKEY|ControlMask|ShiftMask, XK_3, toggletag, "2" }, \
93 { MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \ 93 { MODKEY|ControlMask|ShiftMask, XK_4, toggletag, "3" }, \
94 { MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \ 94 { MODKEY|ControlMask|ShiftMask, XK_5, toggletag, "4" }, \
95 { MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \ 95 { MODKEY|ControlMask|ShiftMask, XK_6, toggletag, "5" }, \
96 { MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \ 96 { MODKEY|ControlMask|ShiftMask, XK_7, toggletag, "6" }, \
97 { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \ 97 { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, "7" }, \
98 { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \ 98 { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, "8" }, \
99 { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ 99 { MODKEY|ShiftMask, XK_q, quit, NULL }, \
100}; 100};
diff --git a/config.default.h b/config.default.h
index 98b847f..6db35f2 100644
--- a/config.default.h
+++ b/config.default.h
@@ -42,55 +42,55 @@ static Layout layout[] = { \
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" } }, \ 45 { MODKEY|ShiftMask, XK_Return, spawn, "exec xterm" }, \
46 { MODKEY, XK_space, setlayout, { .i = -1 } }, \ 46 { MODKEY, XK_space, setlayout, NULL }, \
47 { MODKEY, XK_d, incnmaster, { .i = -1 } }, \ 47 { MODKEY, XK_d, incnmaster, "-1" }, \
48 { MODKEY, XK_i, incnmaster, { .i = 1 } }, \ 48 { MODKEY, XK_i, incnmaster, "1" }, \
49 { MODKEY, XK_h, incmasterw, { .i = -15 } }, \ 49 { MODKEY, XK_h, incmasterw, "-15" }, \
50 { MODKEY, XK_l, incmasterw, { .i = 15 } }, \ 50 { MODKEY, XK_l, incmasterw, "15" }, \
51 { MODKEY, XK_j, focusnext, { 0 } }, \ 51 { MODKEY, XK_j, focusnext, NULL }, \
52 { MODKEY, XK_k, focusprev, { 0 } }, \ 52 { MODKEY, XK_k, focusprev, NULL }, \
53 { MODKEY, XK_m, togglemax, { 0 } }, \ 53 { MODKEY, XK_m, togglemax, NULL }, \
54 { MODKEY, XK_Return, zoom, { 0 } }, \ 54 { MODKEY, XK_Return, zoom, NULL }, \
55 { MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \ 55 { MODKEY|ShiftMask, XK_space, toggleversatile,NULL }, \
56 { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ 56 { MODKEY|ShiftMask, XK_c, killclient, NULL }, \
57 { MODKEY, XK_0, view, { .i = -1 } }, \ 57 { MODKEY, XK_0, view, NULL }, \
58 { MODKEY, XK_1, view, { .i = 0 } }, \ 58 { MODKEY, XK_1, view, "0" }, \
59 { MODKEY, XK_2, view, { .i = 1 } }, \ 59 { MODKEY, XK_2, view, "1" }, \
60 { MODKEY, XK_3, view, { .i = 2 } }, \ 60 { MODKEY, XK_3, view, "2" }, \
61 { MODKEY, XK_4, view, { .i = 3 } }, \ 61 { MODKEY, XK_4, view, "3" }, \
62 { MODKEY, XK_5, view, { .i = 4 } }, \ 62 { MODKEY, XK_5, view, "4" }, \
63 { MODKEY, XK_6, view, { .i = 5 } }, \ 63 { MODKEY, XK_6, view, "5" }, \
64 { MODKEY, XK_7, view, { .i = 6 } }, \ 64 { MODKEY, XK_7, view, "6" }, \
65 { MODKEY, XK_8, view, { .i = 7 } }, \ 65 { MODKEY, XK_8, view, "7" }, \
66 { MODKEY, XK_9, view, { .i = 8 } }, \ 66 { MODKEY, XK_9, view, "8" }, \
67 { MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \ 67 { MODKEY|ControlMask, XK_1, toggleview, "0" }, \
68 { MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \ 68 { MODKEY|ControlMask, XK_2, toggleview, "1" }, \
69 { MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \ 69 { MODKEY|ControlMask, XK_3, toggleview, "2" }, \
70 { MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \ 70 { MODKEY|ControlMask, XK_4, toggleview, "3" }, \
71 { MODKEY|ControlMask, XK_5, toggleview, { .i = 4 } }, \ 71 { MODKEY|ControlMask, XK_5, toggleview, "4" }, \
72 { MODKEY|ControlMask, XK_6, toggleview, { .i = 5 } }, \ 72 { MODKEY|ControlMask, XK_6, toggleview, "5" }, \
73 { MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \ 73 { MODKEY|ControlMask, XK_7, toggleview, "6" }, \
74 { MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \ 74 { MODKEY|ControlMask, XK_8, toggleview, "7" }, \
75 { MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \ 75 { MODKEY|ControlMask, XK_9, toggleview, "8" }, \
76 { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \ 76 { MODKEY|ShiftMask, XK_0, tag, NULL }, \
77 { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ 77 { MODKEY|ShiftMask, XK_1, tag, "0" }, \
78 { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \ 78 { MODKEY|ShiftMask, XK_2, tag, "1" }, \
79 { MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \ 79 { MODKEY|ShiftMask, XK_3, tag, "2" }, \
80 { MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \ 80 { MODKEY|ShiftMask, XK_4, tag, "3" }, \
81 { MODKEY|ShiftMask, XK_5, tag, { .i = 4 } }, \ 81 { MODKEY|ShiftMask, XK_5, tag, "4" }, \
82 { MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \ 82 { MODKEY|ShiftMask, XK_6, tag, "5" }, \
83 { MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \ 83 { MODKEY|ShiftMask, XK_7, tag, "6" }, \
84 { MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \ 84 { MODKEY|ShiftMask, XK_8, tag, "7" }, \
85 { MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \ 85 { MODKEY|ShiftMask, XK_9, tag, "8" }, \
86 { MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \ 86 { MODKEY|ControlMask|ShiftMask, XK_1, toggletag, "0" }, \
87 { MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \ 87 { MODKEY|ControlMask|ShiftMask, XK_2, toggletag, "1" }, \
88 { MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \ 88 { MODKEY|ControlMask|ShiftMask, XK_3, toggletag, "2" }, \
89 { MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \ 89 { MODKEY|ControlMask|ShiftMask, XK_4, toggletag, "3" }, \
90 { MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \ 90 { MODKEY|ControlMask|ShiftMask, XK_5, toggletag, "4" }, \
91 { MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \ 91 { MODKEY|ControlMask|ShiftMask, XK_6, toggletag, "5" }, \
92 { MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \ 92 { MODKEY|ControlMask|ShiftMask, XK_7, toggletag, "6" }, \
93 { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \ 93 { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, "7" }, \
94 { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \ 94 { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, "8" }, \
95 { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ 95 { MODKEY|ShiftMask, XK_q, quit, NULL }, \
96}; 96};
diff --git a/dwm.h b/dwm.h
index a6af9ba..f2ae53f 100644
--- a/dwm.h
+++ b/dwm.h
@@ -41,11 +41,6 @@ enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
41enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ 41enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
42enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ 42enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
43 43
44typedef union {
45 const char *cmd;
46 int i;
47} Arg; /* argument type */
48
49typedef struct { 44typedef struct {
50 int ascent; 45 int ascent;
51 int descent; 46 int descent;
@@ -106,11 +101,11 @@ extern void attach(Client *c); /* attaches c to global client list */
106extern void configure(Client *c); /* send synthetic configure event */ 101extern void configure(Client *c); /* send synthetic configure event */
107extern void detach(Client *c); /* detaches c from global client list */ 102extern void detach(Client *c); /* detaches c from global client list */
108extern void focus(Client *c); /* focus c, c may be NULL */ 103extern void focus(Client *c); /* focus c, c may be NULL */
109extern void killclient(Arg arg); /* kill c nicely */ 104extern void killclient(const char *arg); /* kill c nicely */
110extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ 105extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
111extern void resize(Client *c, int x, int y, 106extern void resize(Client *c, int x, int y,
112 int w, int h, Bool sizehints); /* resize with given coordinates c*/ 107 int w, int h, Bool sizehints); /* resize with given coordinates c*/
113extern void toggleversatile(Arg arg); /* toggles focused client between versatile/and non-versatile state */ 108extern void toggleversatile(const char *arg); /* toggles focused client between versatile/and non-versatile state */
114extern void updatesizehints(Client *c); /* update the size hint variables of c */ 109extern void updatesizehints(Client *c); /* update the size hint variables of c */
115extern void updatetitle(Client *c); /* update the name of c */ 110extern void updatetitle(Client *c); /* update the name of c */
116extern void unmanage(Client *c); /* destroy c */ 111extern void unmanage(Client *c); /* destroy c */
@@ -125,19 +120,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 */ 120extern void grabkeys(void); /* grab all keys defined in config.h */
126 121
127/* layout.c */ 122/* layout.c */
128extern void focusnext(Arg arg); /* focuses next visible client, arg is ignored */ 123extern void focusnext(const char *arg); /* focuses next visible client, arg is ignored */
129extern void focusprev(Arg arg); /* focuses previous visible client, arg is ignored */ 124extern void focusprev(const char *arg); /* focuses previous visible client, arg is ignored */
130extern void incmasterw(Arg arg); /* increments the master width with arg's index value */ 125extern void incmasterw(const char *arg); /* increments the master width with arg's index value */
131extern void incnmaster(Arg arg); /* increments nmaster with arg's index value */ 126extern void incnmaster(const char *arg); /* increments nmaster with arg's index value */
132extern void initlayouts(void); /* initialize layout array */ 127extern void initlayouts(void); /* initialize layout array */
133extern Client *nexttiled(Client *c); /* returns tiled successor of c */ 128extern Client *nexttiled(Client *c); /* returns tiled successor of c */
134extern void restack(void); /* restores z layers of all clients */ 129extern void restack(void); /* restores z layers of all clients */
135extern void setlayout(Arg arg); /* sets layout, -1 toggles */ 130extern void setlayout(const char *arg); /* sets layout, -1 toggles */
136extern void togglemax(Arg arg); /* toggles maximization of versatile client */ 131extern void togglemax(const char *arg); /* toggles maximization of versatile client */
137extern void versatile(void); /* arranges all windows versatile */ 132extern void versatile(void); /* arranges all windows versatile */
138 133
139/* main.c */ 134/* main.c */
140extern void quit(Arg arg); /* quit dwm nicely */ 135extern void quit(const char *arg); /* quit dwm nicely */
141extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ 136extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
142extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ 137extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
143 138
@@ -145,14 +140,14 @@ extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
145extern void compileregs(void); /* initialize regexps of rules defined in config.h */ 140extern void compileregs(void); /* initialize regexps of rules defined in config.h */
146extern Bool isvisible(Client *c); /* returns True if client is visible */ 141extern Bool isvisible(Client *c); /* returns True if client is visible */
147extern void settags(Client *c, Client *trans); /* sets tags of c */ 142extern void settags(Client *c, Client *trans); /* sets tags of c */
148extern void tag(Arg arg); /* tags c with arg's index */ 143extern void tag(const char *arg); /* tags c with arg's index */
149extern void toggletag(Arg arg); /* toggles c tags with arg's index */ 144extern void toggletag(const char *arg); /* toggles c tags with arg's index */
150extern void toggleview(Arg arg); /* toggles the tag with arg's index (in)visible */ 145extern void toggleview(const char *arg); /* toggles the tag with arg's index (in)visible */
151extern void view(Arg arg); /* views the tag with arg's index */ 146extern void view(const char *arg); /* views the tag with arg's index */
152extern void zoom(Arg arg); /* zooms the focused client to master area, arg is ignored */ 147extern void zoom(const char *arg); /* zooms the focused client to master area, arg is ignored */
153 148
154/* util.c */ 149/* util.c */
155extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ 150extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
156extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ 151extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
157extern void spawn(Arg arg); /* forks a new subprocess with arg's cmd */ 152extern void spawn(const char *arg); /* forks a new subprocess with arg's cmd */
158 153
diff --git a/event.c b/event.c
index f765fe1..ae08f86 100644
--- a/event.c
+++ b/event.c
@@ -2,6 +2,7 @@
2 * See LICENSE file for license details. 2 * See LICENSE file for license details.
3 */ 3 */
4#include "dwm.h" 4#include "dwm.h"
5#include <stdio.h>
5#include <stdlib.h> 6#include <stdlib.h>
6#include <X11/keysym.h> 7#include <X11/keysym.h>
7#include <X11/Xatom.h> 8#include <X11/Xatom.h>
@@ -11,8 +12,8 @@
11typedef struct { 12typedef struct {
12 unsigned long mod; 13 unsigned long mod;
13 KeySym keysym; 14 KeySym keysym;
14 void (*func)(Arg arg); 15 void (*func)(const char *arg);
15 Arg arg; 16 const char *arg;
16} Key; 17} Key;
17 18
18KEYS 19KEYS
@@ -112,27 +113,29 @@ resizemouse(Client *c) {
112 113
113static void 114static void
114buttonpress(XEvent *e) { 115buttonpress(XEvent *e) {
115 int x; 116 static char arg[8];
116 Arg a; 117 int i, x;
117 Client *c; 118 Client *c;
118 XButtonPressedEvent *ev = &e->xbutton; 119 XButtonPressedEvent *ev = &e->xbutton;
119 120
121 arg[0] = 0;
120 if(barwin == ev->window) { 122 if(barwin == ev->window) {
121 x = 0; 123 x = 0;
122 for(a.i = 0; a.i < ntags; a.i++) { 124 for(i = 0; i < ntags; i++) {
123 x += textw(tags[a.i]); 125 x += textw(tags[i]);
124 if(ev->x < x) { 126 if(ev->x < x) {
127 snprintf(arg, sizeof arg, "%d", i);
125 if(ev->button == Button1) { 128 if(ev->button == Button1) {
126 if(ev->state & MODKEY) 129 if(ev->state & MODKEY)
127 tag(a); 130 tag(arg);
128 else 131 else
129 view(a); 132 view(arg);
130 } 133 }
131 else if(ev->button == Button3) { 134 else if(ev->button == Button3) {
132 if(ev->state & MODKEY) 135 if(ev->state & MODKEY)
133 toggletag(a); 136 toggletag(arg);
134 else 137 else
135 toggleview(a); 138 toggleview(arg);
136 } 139 }
137 return; 140 return;
138 } 141 }
@@ -140,8 +143,7 @@ buttonpress(XEvent *e) {
140 if(ev->x < x + blw) 143 if(ev->x < x + blw)
141 switch(ev->button) { 144 switch(ev->button) {
142 case Button1: 145 case Button1:
143 a.i = -1; 146 setlayout("-1");
144 setlayout(a);
145 break; 147 break;
146 } 148 }
147 } 149 }
@@ -154,7 +156,7 @@ buttonpress(XEvent *e) {
154 movemouse(c); 156 movemouse(c);
155 } 157 }
156 else if(ev->button == Button2) 158 else if(ev->button == Button2)
157 zoom(a); 159 zoom(NULL);
158 else if(ev->button == Button3 160 else if(ev->button == Button3
159 && (lt->arrange == versatile || c->isversatile) && !c->isfixed) 161 && (lt->arrange == versatile || c->isversatile) && !c->isfixed)
160 { 162 {
diff --git a/layout.c b/layout.c
index 5a7d4b4..8b4c940 100644
--- a/layout.c
+++ b/layout.c
@@ -69,7 +69,7 @@ LAYOUTS
69/* extern */ 69/* extern */
70 70
71void 71void
72focusnext(Arg arg) { 72focusnext(const char *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(const char *arg) {
88 Client *c; 88 Client *c;
89 89
90 if(!sel) 90 if(!sel)
@@ -101,26 +101,29 @@ focusprev(Arg arg) {
101} 101}
102 102
103void 103void
104incmasterw(Arg arg) { 104incmasterw(const char *arg) {
105 int i;
105 if(lt->arrange != tile) 106 if(lt->arrange != tile)
106 return; 107 return;
107 if(arg.i == 0) 108 if(!arg)
108 masterw = MASTERWIDTH; 109 masterw = MASTERWIDTH;
109 else { 110 else {
110 if(waw * (masterw + arg.i) / 1000 >= waw - 2 * BORDERPX 111 i = atoi(arg);
111 || waw * (masterw + arg.i) / 1000 <= 2 * BORDERPX) 112 if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX
113 || waw * (masterw + i) / 1000 <= 2 * BORDERPX)
112 return; 114 return;
113 masterw += arg.i; 115 masterw += i;
114 } 116 }
115 lt->arrange(); 117 lt->arrange();
116} 118}
117 119
118void 120void
119incnmaster(Arg arg) { 121incnmaster(const char *arg) {
120 if((lt->arrange != tile) || (nmaster + arg.i < 1) 122 int i = arg ? atoi(arg) : 0;
121 || (wah / (nmaster + arg.i) <= 2 * BORDERPX)) 123 if((lt->arrange != tile) || (nmaster + i < 1)
124 || (wah / (nmaster + i) <= 2 * BORDERPX))
122 return; 125 return;
123 nmaster += arg.i; 126 nmaster += i;
124 if(sel) 127 if(sel)
125 lt->arrange(); 128 lt->arrange();
126 else 129 else
@@ -170,10 +173,10 @@ restack(void) {
170} 173}
171 174
172void 175void
173setlayout(Arg arg) { 176setlayout(const char *arg) {
174 unsigned int i; 177 unsigned int i;
175 178
176 if(arg.i == -1) { 179 if(!arg) {
177 for(i = 0; i < nlayouts && lt != &layout[i]; i++); 180 for(i = 0; i < nlayouts && lt != &layout[i]; i++);
178 if(i == nlayouts - 1) 181 if(i == nlayouts - 1)
179 lt = &layout[0]; 182 lt = &layout[0];
@@ -181,9 +184,10 @@ setlayout(Arg arg) {
181 lt = &layout[++i]; 184 lt = &layout[++i];
182 } 185 }
183 else { 186 else {
184 if(arg.i < 0 || arg.i >= nlayouts) 187 i = atoi(arg);
188 if(i < 0 || i >= nlayouts)
185 return; 189 return;
186 lt = &layout[arg.i]; 190 lt = &layout[i];
187 } 191 }
188 if(sel) 192 if(sel)
189 lt->arrange(); 193 lt->arrange();
@@ -192,7 +196,7 @@ setlayout(Arg arg) {
192} 196}
193 197
194void 198void
195togglemax(Arg arg) { 199togglemax(const char *arg) {
196 XEvent ev; 200 XEvent ev;
197 201
198 if(!sel || (lt->arrange != versatile && !sel->isversatile) || sel->isfixed) 202 if(!sel || (lt->arrange != versatile && !sel->isversatile) || sel->isfixed)
@@ -234,7 +238,7 @@ versatile(void) {
234} 238}
235 239
236void 240void
237zoom(Arg arg) { 241zoom(const char *arg) {
238 unsigned int n; 242 unsigned int n;
239 Client *c; 243 Client *c;
240 244
diff --git a/main.c b/main.c
index d06a1b3..e6ba20c 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(const char *arg) {
240 readin = running = False; 240 readin = running = False;
241} 241}
242 242
diff --git a/tag.c b/tag.c
index d946309..a96cc62 100644
--- a/tag.c
+++ b/tag.c
@@ -102,49 +102,53 @@ settags(Client *c, Client *trans) {
102} 102}
103 103
104void 104void
105tag(Arg arg) { 105tag(const char *arg) {
106 unsigned int i; 106 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 ? False : True;
112 if(arg.i >= 0 && arg.i < ntags) 112 i = arg ? atoi(arg) : 0;
113 sel->tags[arg.i] = True; 113 if(i >= 0 && i < ntags)
114 sel->tags[i] = True;
114 lt->arrange(); 115 lt->arrange();
115} 116}
116 117
117void 118void
118toggletag(Arg arg) { 119toggletag(const char *arg) {
119 unsigned int i; 120 int i, j;
120 121
121 if(!sel) 122 if(!sel)
122 return; 123 return;
123 sel->tags[arg.i] = !sel->tags[arg.i]; 124 i = arg ? atoi(arg) : 0;
124 for(i = 0; i < ntags && !sel->tags[i]; i++); 125 sel->tags[i] = !sel->tags[i];
125 if(i == ntags) 126 for(j = 0; j < ntags && !sel->tags[j]; j++);
126 sel->tags[arg.i] = True; 127 if(j == ntags)
128 sel->tags[i] = True;
127 lt->arrange(); 129 lt->arrange();
128} 130}
129 131
130void 132void
131toggleview(Arg arg) { 133toggleview(const char *arg) {
132 unsigned int i; 134 int i, j;
133 135
134 seltag[arg.i] = !seltag[arg.i]; 136 i = arg ? atoi(arg) : 0;
135 for(i = 0; i < ntags && !seltag[i]; i++); 137 seltag[i] = !seltag[i];
136 if(i == ntags) 138 for(j = 0; j < ntags && !seltag[j]; i++);
137 seltag[arg.i] = True; /* cannot toggle last view */ 139 if(j == ntags)
140 seltag[i] = True; /* cannot toggle last view */
138 lt->arrange(); 141 lt->arrange();
139} 142}
140 143
141void 144void
142view(Arg arg) { 145view(const char *arg) {
143 unsigned int i; 146 int i;
144 147
145 for(i = 0; i < ntags; i++) 148 for(i = 0; i < ntags; i++)
146 seltag[i] = (arg.i == -1) ? True : False; 149 seltag[i] = arg ? False : True;
147 if(arg.i >= 0 && arg.i < ntags) 150 i = arg ? atoi(arg) : 0;
148 seltag[arg.i] = True; 151 if(i >= 0 && i < ntags)
152 seltag[i] = True;
149 lt->arrange(); 153 lt->arrange();
150} 154}
diff --git a/util.c b/util.c
index b786480..4914cf5 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(const char *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)
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, (char *)NULL);
48 fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg.cmd); 48 fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg);
49 perror(" failed"); 49 perror(" failed");
50 } 50 }
51 exit(0); 51 exit(0);