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