diff options
author | Anselm R. Garbe | 2007-02-22 11:42:08 +0100 |
---|---|---|
committer | Anselm R. Garbe | 2007-02-22 11:42:08 +0100 |
commit | 2c477cf66147d369ae8ff17acdce743c6811ee6a (patch) | |
tree | 121a031caf30be9f6931e37e26cf2469c8c7acfa | |
parent | 986ca73074ef165880c75ee46a4eb6a1b328dc5b (diff) |
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
-rw-r--r-- | client.c | 4 | ||||
-rw-r--r-- | config.arg.h | 108 | ||||
-rw-r--r-- | config.default.h | 102 | ||||
-rw-r--r-- | dwm.h | 35 | ||||
-rw-r--r-- | event.c | 28 | ||||
-rw-r--r-- | layout.c | 38 | ||||
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | tag.c | 50 | ||||
-rw-r--r-- | util.c | 8 |
9 files changed, 190 insertions, 185 deletions
@@ -153,7 +153,7 @@ focus(Client *c) { } void -killclient(Arg arg) { +killclient(const char *arg) { if(!sel) return; if(isprotodel(sel)) @@ -285,7 +285,7 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) { } void -toggleversatile(Arg arg) { +toggleversatile(const char *arg) { if(!sel || lt->arrange == versatile) return; 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[] = { \ static Key key[] = { \ /* modifier key function argument */ \ { MODKEY, XK_p, spawn, \ - { .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \ - " | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \ - "-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \ + "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \ + " | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \ + "-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" }, \ { MODKEY|ShiftMask, XK_Return, spawn, \ - { .cmd = "exec urxvtcd -tr -bg '#292929' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" } }, \ - { MODKEY, XK_space, setlayout, { .i = -1 } }, \ - { MODKEY, XK_d, incnmaster, { .i = -1 } }, \ - { MODKEY, XK_i, incnmaster, { .i = 1 } }, \ - { MODKEY, XK_h, incmasterw, { .i = -15 } }, \ - { MODKEY, XK_l, incmasterw, { .i = 15 } }, \ - { MODKEY, XK_j, focusnext, { 0 } }, \ - { MODKEY, XK_k, focusprev, { 0 } }, \ - { MODKEY, XK_m, togglemax, { 0 } }, \ - { MODKEY, XK_Return, zoom, { 0 } }, \ - { MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \ - { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ - { MODKEY, XK_0, view, { .i = -1 } }, \ - { MODKEY, XK_1, view, { .i = 0 } }, \ - { MODKEY, XK_2, view, { .i = 1 } }, \ - { MODKEY, XK_3, view, { .i = 2 } }, \ - { MODKEY, XK_4, view, { .i = 3 } }, \ - { MODKEY, XK_5, view, { .i = 4 } }, \ - { MODKEY, XK_6, view, { .i = 5 } }, \ - { MODKEY, XK_7, view, { .i = 6 } }, \ - { MODKEY, XK_8, view, { .i = 7 } }, \ - { MODKEY, XK_9, view, { .i = 8 } }, \ - { MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \ - { MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \ - { MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \ - { MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \ - { MODKEY|ControlMask, XK_5, toggleview, { .i = 4 } }, \ - { MODKEY|ControlMask, XK_6, toggleview, { .i = 5 } }, \ - { MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \ - { MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \ - { MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \ - { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \ - { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ - { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \ - { MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \ - { MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \ - { MODKEY|ShiftMask, XK_5, tag, { .i = 4 } }, \ - { MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \ - { MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \ - { MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \ - { MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \ - { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ + "exec urxvtcd -tr -bg '#292929' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" }, \ + { MODKEY, XK_space, setlayout, NULL }, \ + { MODKEY, XK_d, incnmaster, "-1" }, \ + { MODKEY, XK_i, incnmaster, "1" }, \ + { MODKEY, XK_h, incmasterw, "-15" }, \ + { MODKEY, XK_l, incmasterw, "15" }, \ + { MODKEY, XK_j, focusnext, NULL }, \ + { MODKEY, XK_k, focusprev, NULL }, \ + { MODKEY, XK_m, togglemax, NULL }, \ + { MODKEY, XK_Return, zoom, NULL }, \ + { MODKEY|ShiftMask, XK_space, toggleversatile,NULL }, \ + { MODKEY|ShiftMask, XK_c, killclient, NULL }, \ + { MODKEY, XK_0, view, NULL }, \ + { MODKEY, XK_1, view, "0" }, \ + { MODKEY, XK_2, view, "1" }, \ + { MODKEY, XK_3, view, "2" }, \ + { MODKEY, XK_4, view, "3" }, \ + { MODKEY, XK_5, view, "4" }, \ + { MODKEY, XK_6, view, "5" }, \ + { MODKEY, XK_7, view, "6" }, \ + { MODKEY, XK_8, view, "7" }, \ + { MODKEY, XK_9, view, "8" }, \ + { MODKEY|ControlMask, XK_1, toggleview, "0" }, \ + { MODKEY|ControlMask, XK_2, toggleview, "1" }, \ + { MODKEY|ControlMask, XK_3, toggleview, "2" }, \ + { MODKEY|ControlMask, XK_4, toggleview, "3" }, \ + { MODKEY|ControlMask, XK_5, toggleview, "4" }, \ + { MODKEY|ControlMask, XK_6, toggleview, "5" }, \ + { MODKEY|ControlMask, XK_7, toggleview, "6" }, \ + { MODKEY|ControlMask, XK_8, toggleview, "7" }, \ + { MODKEY|ControlMask, XK_9, toggleview, "8" }, \ + { MODKEY|ShiftMask, XK_0, tag, NULL }, \ + { MODKEY|ShiftMask, XK_1, tag, "0" }, \ + { MODKEY|ShiftMask, XK_2, tag, "1" }, \ + { MODKEY|ShiftMask, XK_3, tag, "2" }, \ + { MODKEY|ShiftMask, XK_4, tag, "3" }, \ + { MODKEY|ShiftMask, XK_5, tag, "4" }, \ + { MODKEY|ShiftMask, XK_6, tag, "5" }, \ + { MODKEY|ShiftMask, XK_7, tag, "6" }, \ + { MODKEY|ShiftMask, XK_8, tag, "7" }, \ + { MODKEY|ShiftMask, XK_9, tag, "8" }, \ + { MODKEY|ControlMask|ShiftMask, XK_1, toggletag, "0" }, \ + { MODKEY|ControlMask|ShiftMask, XK_2, toggletag, "1" }, \ + { MODKEY|ControlMask|ShiftMask, XK_3, toggletag, "2" }, \ + { MODKEY|ControlMask|ShiftMask, XK_4, toggletag, "3" }, \ + { MODKEY|ControlMask|ShiftMask, XK_5, toggletag, "4" }, \ + { MODKEY|ControlMask|ShiftMask, XK_6, toggletag, "5" }, \ + { MODKEY|ControlMask|ShiftMask, XK_7, toggletag, "6" }, \ + { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, "7" }, \ + { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, "8" }, \ + { MODKEY|ShiftMask, XK_q, quit, NULL }, \ }; 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[] = { \ #define KEYS \ static Key key[] = { \ /* modifier key function argument */ \ - { MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \ - { MODKEY, XK_space, setlayout, { .i = -1 } }, \ - { MODKEY, XK_d, incnmaster, { .i = -1 } }, \ - { MODKEY, XK_i, incnmaster, { .i = 1 } }, \ - { MODKEY, XK_h, incmasterw, { .i = -15 } }, \ - { MODKEY, XK_l, incmasterw, { .i = 15 } }, \ - { MODKEY, XK_j, focusnext, { 0 } }, \ - { MODKEY, XK_k, focusprev, { 0 } }, \ - { MODKEY, XK_m, togglemax, { 0 } }, \ - { MODKEY, XK_Return, zoom, { 0 } }, \ - { MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \ - { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ - { MODKEY, XK_0, view, { .i = -1 } }, \ - { MODKEY, XK_1, view, { .i = 0 } }, \ - { MODKEY, XK_2, view, { .i = 1 } }, \ - { MODKEY, XK_3, view, { .i = 2 } }, \ - { MODKEY, XK_4, view, { .i = 3 } }, \ - { MODKEY, XK_5, view, { .i = 4 } }, \ - { MODKEY, XK_6, view, { .i = 5 } }, \ - { MODKEY, XK_7, view, { .i = 6 } }, \ - { MODKEY, XK_8, view, { .i = 7 } }, \ - { MODKEY, XK_9, view, { .i = 8 } }, \ - { MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \ - { MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \ - { MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \ - { MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \ - { MODKEY|ControlMask, XK_5, toggleview, { .i = 4 } }, \ - { MODKEY|ControlMask, XK_6, toggleview, { .i = 5 } }, \ - { MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \ - { MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \ - { MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \ - { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \ - { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ - { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \ - { MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \ - { MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \ - { MODKEY|ShiftMask, XK_5, tag, { .i = 4 } }, \ - { MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \ - { MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \ - { MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \ - { MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \ - { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \ - { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ + { MODKEY|ShiftMask, XK_Return, spawn, "exec xterm" }, \ + { MODKEY, XK_space, setlayout, NULL }, \ + { MODKEY, XK_d, incnmaster, "-1" }, \ + { MODKEY, XK_i, incnmaster, "1" }, \ + { MODKEY, XK_h, incmasterw, "-15" }, \ + { MODKEY, XK_l, incmasterw, "15" }, \ + { MODKEY, XK_j, focusnext, NULL }, \ + { MODKEY, XK_k, focusprev, NULL }, \ + { MODKEY, XK_m, togglemax, NULL }, \ + { MODKEY, XK_Return, zoom, NULL }, \ + { MODKEY|ShiftMask, XK_space, toggleversatile,NULL }, \ + { MODKEY|ShiftMask, XK_c, killclient, NULL }, \ + { MODKEY, XK_0, view, NULL }, \ + { MODKEY, XK_1, view, "0" }, \ + { MODKEY, XK_2, view, "1" }, \ + { MODKEY, XK_3, view, "2" }, \ + { MODKEY, XK_4, view, "3" }, \ + { MODKEY, XK_5, view, "4" }, \ + { MODKEY, XK_6, view, "5" }, \ + { MODKEY, XK_7, view, "6" }, \ + { MODKEY, XK_8, view, "7" }, \ + { MODKEY, XK_9, view, "8" }, \ + { MODKEY|ControlMask, XK_1, toggleview, "0" }, \ + { MODKEY|ControlMask, XK_2, toggleview, "1" }, \ + { MODKEY|ControlMask, XK_3, toggleview, "2" }, \ + { MODKEY|ControlMask, XK_4, toggleview, "3" }, \ + { MODKEY|ControlMask, XK_5, toggleview, "4" }, \ + { MODKEY|ControlMask, XK_6, toggleview, "5" }, \ + { MODKEY|ControlMask, XK_7, toggleview, "6" }, \ + { MODKEY|ControlMask, XK_8, toggleview, "7" }, \ + { MODKEY|ControlMask, XK_9, toggleview, "8" }, \ + { MODKEY|ShiftMask, XK_0, tag, NULL }, \ + { MODKEY|ShiftMask, XK_1, tag, "0" }, \ + { MODKEY|ShiftMask, XK_2, tag, "1" }, \ + { MODKEY|ShiftMask, XK_3, tag, "2" }, \ + { MODKEY|ShiftMask, XK_4, tag, "3" }, \ + { MODKEY|ShiftMask, XK_5, tag, "4" }, \ + { MODKEY|ShiftMask, XK_6, tag, "5" }, \ + { MODKEY|ShiftMask, XK_7, tag, "6" }, \ + { MODKEY|ShiftMask, XK_8, tag, "7" }, \ + { MODKEY|ShiftMask, XK_9, tag, "8" }, \ + { MODKEY|ControlMask|ShiftMask, XK_1, toggletag, "0" }, \ + { MODKEY|ControlMask|ShiftMask, XK_2, toggletag, "1" }, \ + { MODKEY|ControlMask|ShiftMask, XK_3, toggletag, "2" }, \ + { MODKEY|ControlMask|ShiftMask, XK_4, toggletag, "3" }, \ + { MODKEY|ControlMask|ShiftMask, XK_5, toggletag, "4" }, \ + { MODKEY|ControlMask|ShiftMask, XK_6, toggletag, "5" }, \ + { MODKEY|ControlMask|ShiftMask, XK_7, toggletag, "6" }, \ + { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, "7" }, \ + { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, "8" }, \ + { MODKEY|ShiftMask, XK_q, quit, NULL }, \ }; @@ -41,11 +41,6 @@ enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ -typedef union { - const char *cmd; - int i; -} Arg; /* argument type */ - typedef struct { int ascent; int descent; @@ -106,11 +101,11 @@ extern void attach(Client *c); /* attaches c to global client list */ extern void configure(Client *c); /* send synthetic configure event */ extern void detach(Client *c); /* detaches c from global client list */ extern void focus(Client *c); /* focus c, c may be NULL */ -extern void killclient(Arg arg); /* kill c nicely */ +extern void killclient(const char *arg); /* kill c nicely */ extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ extern void resize(Client *c, int x, int y, int w, int h, Bool sizehints); /* resize with given coordinates c*/ -extern void toggleversatile(Arg arg); /* toggles focused client between versatile/and non-versatile state */ +extern void toggleversatile(const char *arg); /* toggles focused client between versatile/and non-versatile state */ extern void updatesizehints(Client *c); /* update the size hint variables of c */ extern void updatetitle(Client *c); /* update the name of c */ extern void unmanage(Client *c); /* destroy c */ @@ -125,19 +120,19 @@ extern unsigned int textw(const char *text); /* return the width of text in px*/ extern void grabkeys(void); /* grab all keys defined in config.h */ /* layout.c */ -extern void focusnext(Arg arg); /* focuses next visible client, arg is ignored */ -extern void focusprev(Arg arg); /* focuses previous visible client, arg is ignored */ -extern void incmasterw(Arg arg); /* increments the master width with arg's index value */ -extern void incnmaster(Arg arg); /* increments nmaster with arg's index value */ +extern void focusnext(const char *arg); /* focuses next visible client, arg is ignored */ +extern void focusprev(const char *arg); /* focuses previous visible client, arg is ignored */ +extern void incmasterw(const char *arg); /* increments the master width with arg's index value */ +extern void incnmaster(const char *arg); /* increments nmaster with arg's index value */ extern void initlayouts(void); /* initialize layout array */ extern Client *nexttiled(Client *c); /* returns tiled successor of c */ extern void restack(void); /* restores z layers of all clients */ -extern void setlayout(Arg arg); /* sets layout, -1 toggles */ -extern void togglemax(Arg arg); /* toggles maximization of versatile client */ +extern void setlayout(const char *arg); /* sets layout, -1 toggles */ +extern void togglemax(const char *arg); /* toggles maximization of versatile client */ extern void versatile(void); /* arranges all windows versatile */ /* main.c */ -extern void quit(Arg arg); /* quit dwm nicely */ +extern void quit(const char *arg); /* quit dwm nicely */ extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ @@ -145,14 +140,14 @@ extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ extern void compileregs(void); /* initialize regexps of rules defined in config.h */ extern Bool isvisible(Client *c); /* returns True if client is visible */ extern void settags(Client *c, Client *trans); /* sets tags of c */ -extern void tag(Arg arg); /* tags c with arg's index */ -extern void toggletag(Arg arg); /* toggles c tags with arg's index */ -extern void toggleview(Arg arg); /* toggles the tag with arg's index (in)visible */ -extern void view(Arg arg); /* views the tag with arg's index */ -extern void zoom(Arg arg); /* zooms the focused client to master area, arg is ignored */ +extern void tag(const char *arg); /* tags c with arg's index */ +extern void toggletag(const char *arg); /* toggles c tags with arg's index */ +extern void toggleview(const char *arg); /* toggles the tag with arg's index (in)visible */ +extern void view(const char *arg); /* views the tag with arg's index */ +extern void zoom(const char *arg); /* zooms the focused client to master area, arg is ignored */ /* util.c */ extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ -extern void spawn(Arg arg); /* forks a new subprocess with arg's cmd */ +extern void spawn(const char *arg); /* forks a new subprocess with arg's cmd */ @@ -2,6 +2,7 @@ * See LICENSE file for license details. */ #include "dwm.h" +#include <stdio.h> #include <stdlib.h> #include <X11/keysym.h> #include <X11/Xatom.h> @@ -11,8 +12,8 @@ typedef struct { unsigned long mod; KeySym keysym; - void (*func)(Arg arg); - Arg arg; + void (*func)(const char *arg); + const char *arg; } Key; KEYS @@ -112,27 +113,29 @@ resizemouse(Client *c) { static void buttonpress(XEvent *e) { - int x; - Arg a; + static char arg[8]; + int i, x; Client *c; XButtonPressedEvent *ev = &e->xbutton; + arg[0] = 0; if(barwin == ev->window) { x = 0; - for(a.i = 0; a.i < ntags; a.i++) { - x += textw(tags[a.i]); + for(i = 0; i < ntags; i++) { + x += textw(tags[i]); if(ev->x < x) { + snprintf(arg, sizeof arg, "%d", i); if(ev->button == Button1) { if(ev->state & MODKEY) - tag(a); + tag(arg); else - view(a); + view(arg); } else if(ev->button == Button3) { if(ev->state & MODKEY) - toggletag(a); + toggletag(arg); else - toggleview(a); + toggleview(arg); } return; } @@ -140,8 +143,7 @@ buttonpress(XEvent *e) { if(ev->x < x + blw) switch(ev->button) { case Button1: - a.i = -1; - setlayout(a); + setlayout("-1"); break; } } @@ -154,7 +156,7 @@ buttonpress(XEvent *e) { movemouse(c); } else if(ev->button == Button2) - zoom(a); + zoom(NULL); else if(ev->button == Button3 && (lt->arrange == versatile || c->isversatile) && !c->isfixed) { @@ -69,7 +69,7 @@ LAYOUTS /* extern */ void -focusnext(Arg arg) { +focusnext(const char *arg) { Client *c; if(!sel) @@ -84,7 +84,7 @@ focusnext(Arg arg) { } void -focusprev(Arg arg) { +focusprev(const char *arg) { Client *c; if(!sel) @@ -101,26 +101,29 @@ focusprev(Arg arg) { } void -incmasterw(Arg arg) { +incmasterw(const char *arg) { + int i; if(lt->arrange != tile) return; - if(arg.i == 0) + if(!arg) masterw = MASTERWIDTH; else { - if(waw * (masterw + arg.i) / 1000 >= waw - 2 * BORDERPX - || waw * (masterw + arg.i) / 1000 <= 2 * BORDERPX) + i = atoi(arg); + if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX + || waw * (masterw + i) / 1000 <= 2 * BORDERPX) return; - masterw += arg.i; + masterw += i; } lt->arrange(); } void -incnmaster(Arg arg) { - if((lt->arrange != tile) || (nmaster + arg.i < 1) - || (wah / (nmaster + arg.i) <= 2 * BORDERPX)) +incnmaster(const char *arg) { + int i = arg ? atoi(arg) : 0; + if((lt->arrange != tile) || (nmaster + i < 1) + || (wah / (nmaster + i) <= 2 * BORDERPX)) return; - nmaster += arg.i; + nmaster += i; if(sel) lt->arrange(); else @@ -170,10 +173,10 @@ restack(void) { } void -setlayout(Arg arg) { +setlayout(const char *arg) { unsigned int i; - if(arg.i == -1) { + if(!arg) { for(i = 0; i < nlayouts && lt != &layout[i]; i++); if(i == nlayouts - 1) lt = &layout[0]; @@ -181,9 +184,10 @@ setlayout(Arg arg) { lt = &layout[++i]; } else { - if(arg.i < 0 || arg.i >= nlayouts) + i = atoi(arg); + if(i < 0 || i >= nlayouts) return; - lt = &layout[arg.i]; + lt = &layout[i]; } if(sel) lt->arrange(); @@ -192,7 +196,7 @@ setlayout(Arg arg) { } void -togglemax(Arg arg) { +togglemax(const char *arg) { XEvent ev; if(!sel || (lt->arrange != versatile && !sel->isversatile) || sel->isfixed) @@ -234,7 +238,7 @@ versatile(void) { } void -zoom(Arg arg) { +zoom(const char *arg) { unsigned int n; Client *c; @@ -236,7 +236,7 @@ sendevent(Window w, Atom a, long value) { } void -quit(Arg arg) { +quit(const char *arg) { readin = running = False; } @@ -102,49 +102,53 @@ settags(Client *c, Client *trans) { } void -tag(Arg arg) { - unsigned int i; +tag(const char *arg) { + int i; if(!sel) return; for(i = 0; i < ntags; i++) - sel->tags[i] = (arg.i == -1) ? True : False; - if(arg.i >= 0 && arg.i < ntags) - sel->tags[arg.i] = True; + sel->tags[i] = arg ? False : True; + i = arg ? atoi(arg) : 0; + if(i >= 0 && i < ntags) + sel->tags[i] = True; lt->arrange(); } void -toggletag(Arg arg) { - unsigned int i; +toggletag(const char *arg) { + int i, j; if(!sel) return; - sel->tags[arg.i] = !sel->tags[arg.i]; - for(i = 0; i < ntags && !sel->tags[i]; i++); - if(i == ntags) - sel->tags[arg.i] = True; + i = arg ? atoi(arg) : 0; + sel->tags[i] = !sel->tags[i]; + for(j = 0; j < ntags && !sel->tags[j]; j++); + if(j == ntags) + sel->tags[i] = True; lt->arrange(); } void -toggleview(Arg arg) { - unsigned int i; - - seltag[arg.i] = !seltag[arg.i]; - for(i = 0; i < ntags && !seltag[i]; i++); - if(i == ntags) - seltag[arg.i] = True; /* cannot toggle last view */ +toggleview(const char *arg) { + int i, j; + + i = arg ? atoi(arg) : 0; + seltag[i] = !seltag[i]; + for(j = 0; j < ntags && !seltag[j]; i++); + if(j == ntags) + seltag[i] = True; /* cannot toggle last view */ lt->arrange(); } void -view(Arg arg) { - unsigned int i; +view(const char *arg) { + int i; for(i = 0; i < ntags; i++) - seltag[i] = (arg.i == -1) ? True : False; - if(arg.i >= 0 && arg.i < ntags) - seltag[arg.i] = True; + seltag[i] = arg ? False : True; + i = arg ? atoi(arg) : 0; + if(i >= 0 && i < ntags) + seltag[i] = True; lt->arrange(); } @@ -30,12 +30,12 @@ eprint(const char *errstr, ...) { } void -spawn(Arg arg) { +spawn(const char *arg) { static char *shell = NULL; if(!shell && !(shell = getenv("SHELL"))) shell = "/bin/sh"; - if(!arg.cmd) + if(!arg) return; /* The double-fork construct avoids zombie processes and keeps the code * clean from stupid signal handlers. */ @@ -44,8 +44,8 @@ spawn(Arg arg) { if(dpy) close(ConnectionNumber(dpy)); setsid(); - execl(shell, shell, "-c", arg.cmd, (char *)NULL); - fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg.cmd); + execl(shell, shell, "-c", arg, (char *)NULL); + fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg); perror(" failed"); } exit(0); |