aewl

changeset 586:c2ddd15b199e

changing Key.func into Key.func[NFUNCS], this allows sequences execution of functions per keypress (avoids implementing useless masterfunctions which call atomic ones)
author arg@mig29
date Mon, 27 Nov 2006 13:21:38 +0100
parents 83807f4d18e9
children fede0f2de723
files config.arg.h config.default.h event.c
diffstat 3 files changed, 72 insertions(+), 69 deletions(-) [+]
line diff
     1.1 --- a/config.arg.h	Mon Nov 27 11:05:47 2006 +0100
     1.2 +++ b/config.arg.h	Mon Nov 27 13:21:38 2006 +0100
     1.3 @@ -17,45 +17,46 @@
     1.4  #define STATUSBGCOLOR		"#222222"
     1.5  #define STATUSFGCOLOR		"#99ccff"
     1.6  
     1.7 -#define MASTER			600 /* per thousand */
     1.8 +#define MASTER			600		/* per thousand */
     1.9  #define MODKEY			Mod1Mask
    1.10 -#define SNAP			40 /* pixel */
    1.11 +#define NFUNCS			1		/* number of funcs per key */
    1.12 +#define SNAP			40		/* pixel */
    1.13  
    1.14  #define KEYS \
    1.15  static Key key[] = { \
    1.16 -	/* modifier			key		function	arguments */ \
    1.17 -	{ MODKEY|ShiftMask,		XK_Return,	spawn, \
    1.18 +	/* modifier			key		functions		arguments */ \
    1.19 +	{ MODKEY|ShiftMask,		XK_Return,	{ spawn }, \
    1.20  		{ .cmd = "exec urxvtc -tr -bg black -fg '#eeeeee' -cr '#eeeeee' +sb -fn '"FONT"'" } }, \
    1.21 -	{ MODKEY,			XK_p,		spawn, \
    1.22 +	{ MODKEY,			XK_p,		{ spawn }, \
    1.23  		{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
    1.24  			" | dmenu -font '"FONT"' -normbg '"NORMBGCOLOR"' -normfg '"NORMFGCOLOR"' " \
    1.25  			"-selbg '"SELBGCOLOR"' -selfg '"SELFGCOLOR"')\" && exec $exe" } }, \
    1.26 -	{ MODKEY,			XK_j,		focusnext,	{ 0 } }, \
    1.27 -	{ MODKEY,			XK_k,		focusprev,	{ 0 } }, \
    1.28 -	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \
    1.29 -	{ MODKEY,			XK_g,		resizemaster,	{ .i = 15 } }, \
    1.30 -	{ MODKEY,			XK_s,		resizemaster,	{ .i = -15 } }, \
    1.31 -	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \
    1.32 -	{ MODKEY|ShiftMask,		XK_2,		tag,		{ .i = 1 } }, \
    1.33 -	{ MODKEY|ShiftMask,		XK_3,		tag,		{ .i = 2 } }, \
    1.34 -	{ MODKEY|ShiftMask,		XK_4,		tag,		{ .i = 3 } }, \
    1.35 -	{ MODKEY|ControlMask|ShiftMask,	XK_1,		toggletag,	{ .i = 0 } }, \
    1.36 -	{ MODKEY|ControlMask|ShiftMask,	XK_2,		toggletag,	{ .i = 1 } }, \
    1.37 -	{ MODKEY|ControlMask|ShiftMask,	XK_3,		toggletag,	{ .i = 2 } }, \
    1.38 -	{ MODKEY|ControlMask|ShiftMask,	XK_4,		toggletag,	{ .i = 3 } }, \
    1.39 -	{ MODKEY|ShiftMask,		XK_c,		killclient,	{ 0 } }, \
    1.40 -	{ MODKEY,			XK_space,	togglemode,	{ 0 } }, \
    1.41 -	{ MODKEY|ShiftMask,		XK_space,	togglefloat,	{ 0 } }, \
    1.42 -	{ MODKEY,			XK_0,		viewall,	{ 0 } }, \
    1.43 -	{ MODKEY,			XK_1,		view,		{ .i = 0 } }, \
    1.44 -	{ MODKEY,			XK_2,		view,		{ .i = 1 } }, \
    1.45 -	{ MODKEY,			XK_3,		view,		{ .i = 2 } }, \
    1.46 -	{ MODKEY,			XK_4,		view,		{ .i = 3 } }, \
    1.47 -	{ MODKEY|ControlMask,		XK_1,		toggleview,	{ .i = 0 } }, \
    1.48 -	{ MODKEY|ControlMask,		XK_2,		toggleview,	{ .i = 1 } }, \
    1.49 -	{ MODKEY|ControlMask,		XK_3,		toggleview,	{ .i = 2 } }, \
    1.50 -	{ MODKEY|ControlMask,		XK_4,		toggleview,	{ .i = 3 } }, \
    1.51 -	{ MODKEY|ShiftMask,		XK_q,		quit,		{ 0 } }, \
    1.52 +	{ MODKEY,			XK_j,		{ focusnext },		{ 0 } }, \
    1.53 +	{ MODKEY,			XK_k,		{ focusprev },		{ 0 } }, \
    1.54 +	{ MODKEY,			XK_Return,	{ zoom },		{ 0 } }, \
    1.55 +	{ MODKEY,			XK_g,		{ resizemaster },	{ .i = 15 } }, \
    1.56 +	{ MODKEY,			XK_s,		{ resizemaster },	{ .i = -15 } }, \
    1.57 +	{ MODKEY|ShiftMask,		XK_1,		{ tag },		{ .i = 0 } }, \
    1.58 +	{ MODKEY|ShiftMask,		XK_2,		{ tag },		{ .i = 1 } }, \
    1.59 +	{ MODKEY|ShiftMask,		XK_3,		{ tag },		{ .i = 2 } }, \
    1.60 +	{ MODKEY|ShiftMask,		XK_4,		{ tag },		{ .i = 3 } }, \
    1.61 +	{ MODKEY|ControlMask|ShiftMask,	XK_1,		{ toggletag },		{ .i = 0 } }, \
    1.62 +	{ MODKEY|ControlMask|ShiftMask,	XK_2,		{ toggletag },		{ .i = 1 } }, \
    1.63 +	{ MODKEY|ControlMask|ShiftMask,	XK_3,		{ toggletag },		{ .i = 2 } }, \
    1.64 +	{ MODKEY|ControlMask|ShiftMask,	XK_4,		{ toggletag },		{ .i = 3 } }, \
    1.65 +	{ MODKEY|ShiftMask,		XK_c,		{ killclient },		{ 0 } }, \
    1.66 +	{ MODKEY,			XK_space,	{ togglemode },		{ 0 } }, \
    1.67 +	{ MODKEY|ShiftMask,		XK_space,	{ togglefloat },	{ 0 } }, \
    1.68 +	{ MODKEY,			XK_0,		{ viewall },		{ 0 } }, \
    1.69 +	{ MODKEY,			XK_1,		{ view },		{ .i = 0 } }, \
    1.70 +	{ MODKEY,			XK_2,		{ view },		{ .i = 1 } }, \
    1.71 +	{ MODKEY,			XK_3,		{ view },		{ .i = 2 } }, \
    1.72 +	{ MODKEY,			XK_4,		{ view },		{ .i = 3 } }, \
    1.73 +	{ MODKEY|ControlMask,		XK_1,		{ toggleview },		{ .i = 0 } }, \
    1.74 +	{ MODKEY|ControlMask,		XK_2,		{ toggleview },		{ .i = 1 } }, \
    1.75 +	{ MODKEY|ControlMask,		XK_3,		{ toggleview },		{ .i = 2 } }, \
    1.76 +	{ MODKEY|ControlMask,		XK_4,		{ toggleview },		{ .i = 3 } }, \
    1.77 +	{ MODKEY|ShiftMask,		XK_q,		{ quit },		{ 0 } }, \
    1.78  };
    1.79  
    1.80  #define RULES \
     2.1 --- a/config.default.h	Mon Nov 27 11:05:47 2006 +0100
     2.2 +++ b/config.default.h	Mon Nov 27 13:21:38 2006 +0100
     2.3 @@ -17,44 +17,45 @@
     2.4  #define STATUSBGCOLOR		"#dddddd"
     2.5  #define STATUSFGCOLOR		"#222222"
     2.6  
     2.7 -#define MASTER			600 /* per thousand */
     2.8 +#define MASTER			600		/* per thousand */
     2.9  #define MODKEY			Mod1Mask
    2.10 -#define SNAP			20 /* pixel */
    2.11 +#define NFUNCS			1		/* number of funcs per key */
    2.12 +#define SNAP			20		/* pixel */
    2.13  
    2.14  #define KEYS \
    2.15  static Key key[] = { \
    2.16 -	/* modifier			key		function	arguments */ \
    2.17 -	{ MODKEY|ShiftMask,		XK_Return,	spawn,		{ .cmd = "exec xterm" } }, \
    2.18 -	{ MODKEY,			XK_Tab,		focusnext,	{ 0 } }, \
    2.19 -	{ MODKEY|ShiftMask,		XK_Tab,		focusprev,	{ 0 } }, \
    2.20 -	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \
    2.21 -	{ MODKEY,			XK_g,		resizemaster,	{ .i = 15 } }, \
    2.22 -	{ MODKEY,			XK_s,		resizemaster,	{ .i = -15 } }, \
    2.23 -	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \
    2.24 -	{ MODKEY|ShiftMask,		XK_2,		tag,		{ .i = 1 } }, \
    2.25 -	{ MODKEY|ShiftMask,		XK_3,		tag,		{ .i = 2 } }, \
    2.26 -	{ MODKEY|ShiftMask,		XK_4,		tag,		{ .i = 3 } }, \
    2.27 -	{ MODKEY|ShiftMask,		XK_5,		tag,		{ .i = 4 } }, \
    2.28 -	{ MODKEY|ControlMask|ShiftMask,	XK_1,		toggletag,	{ .i = 0 } }, \
    2.29 -	{ MODKEY|ControlMask|ShiftMask,	XK_2,		toggletag,	{ .i = 1 } }, \
    2.30 -	{ MODKEY|ControlMask|ShiftMask,	XK_3,		toggletag,	{ .i = 2 } }, \
    2.31 -	{ MODKEY|ControlMask|ShiftMask,	XK_4,		toggletag,	{ .i = 3 } }, \
    2.32 -	{ MODKEY|ControlMask|ShiftMask,	XK_5,		toggletag,	{ .i = 4 } }, \
    2.33 -	{ MODKEY|ShiftMask,		XK_c,		killclient,	{ 0 } }, \
    2.34 -	{ MODKEY,			XK_space,	togglemode,	{ 0 } }, \
    2.35 -	{ MODKEY|ShiftMask,		XK_space,	togglefloat,	{ 0 } }, \
    2.36 -	{ MODKEY,			XK_0,		viewall,	{ 0 } }, \
    2.37 -	{ MODKEY,			XK_1,		view,		{ .i = 0 } }, \
    2.38 -	{ MODKEY,			XK_2,		view,		{ .i = 1 } }, \
    2.39 -	{ MODKEY,			XK_3,		view,		{ .i = 2 } }, \
    2.40 -	{ MODKEY,			XK_4,		view,		{ .i = 3 } }, \
    2.41 -	{ MODKEY,			XK_5,		view,		{ .i = 4 } }, \
    2.42 -	{ MODKEY|ControlMask,		XK_1,		toggleview,	{ .i = 0 } }, \
    2.43 -	{ MODKEY|ControlMask,		XK_2,		toggleview,	{ .i = 1 } }, \
    2.44 -	{ MODKEY|ControlMask,		XK_3,		toggleview,	{ .i = 2 } }, \
    2.45 -	{ MODKEY|ControlMask,		XK_4,		toggleview,	{ .i = 3 } }, \
    2.46 -	{ MODKEY|ControlMask,		XK_5,		toggleview,	{ .i = 4 } }, \
    2.47 -	{ MODKEY|ShiftMask,		XK_q,		quit,		{ 0 } }, \
    2.48 +	/* modifier			key		functions		arguments */ \
    2.49 +	{ MODKEY|ShiftMask,		XK_Return,	{ spawn },		{ .cmd = "exec xterm" } }, \
    2.50 +	{ MODKEY,			XK_Tab,		{ focusnext },		{ 0 } }, \
    2.51 +	{ MODKEY|ShiftMask,		XK_Tab,		{ focusprev },		{ 0 } }, \
    2.52 +	{ MODKEY,			XK_Return,	{ zoom },		{ 0 } }, \
    2.53 +	{ MODKEY,			XK_g,		{ resizemaster },	{ .i = 15 } }, \
    2.54 +	{ MODKEY,			XK_s,		{ resizemaster },	{ .i = -15 } }, \
    2.55 +	{ MODKEY|ShiftMask,		XK_1,		{ tag },		{ .i = 0 } }, \
    2.56 +	{ MODKEY|ShiftMask,		XK_2,		{ tag },		{ .i = 1 } }, \
    2.57 +	{ MODKEY|ShiftMask,		XK_3,		{ tag },		{ .i = 2 } }, \
    2.58 +	{ MODKEY|ShiftMask,		XK_4,		{ tag },		{ .i = 3 } }, \
    2.59 +	{ MODKEY|ShiftMask,		XK_5,		{ tag },		{ .i = 4 } }, \
    2.60 +	{ MODKEY|ControlMask|ShiftMask,	XK_1,		{ toggletag },		{ .i = 0 } }, \
    2.61 +	{ MODKEY|ControlMask|ShiftMask,	XK_2,		{ toggletag },		{ .i = 1 } }, \
    2.62 +	{ MODKEY|ControlMask|ShiftMask,	XK_3,		{ toggletag },		{ .i = 2 } }, \
    2.63 +	{ MODKEY|ControlMask|ShiftMask,	XK_4,		{ toggletag },		{ .i = 3 } }, \
    2.64 +	{ MODKEY|ControlMask|ShiftMask,	XK_5,		{ toggletag },		{ .i = 4 } }, \
    2.65 +	{ MODKEY|ShiftMask,		XK_c,		{ killclient },		{ 0 } }, \
    2.66 +	{ MODKEY,			XK_space,	{ togglemode },		{ 0 } }, \
    2.67 +	{ MODKEY|ShiftMask,		XK_space,	{ togglefloat },	{ 0 } }, \
    2.68 +	{ MODKEY,			XK_0,		{ viewall },		{ 0 } }, \
    2.69 +	{ MODKEY,			XK_1,		{ view },		{ .i = 0 } }, \
    2.70 +	{ MODKEY,			XK_2,		{ view },		{ .i = 1 } }, \
    2.71 +	{ MODKEY,			XK_3,		{ view },		{ .i = 2 } }, \
    2.72 +	{ MODKEY,			XK_4,		{ view },		{ .i = 3 } }, \
    2.73 +	{ MODKEY,			XK_5,		{ view },		{ .i = 4 } }, \
    2.74 +	{ MODKEY|ControlMask,		XK_1,		{ toggleview },		{ .i = 0 } }, \
    2.75 +	{ MODKEY|ControlMask,		XK_2,		{ toggleview },		{ .i = 1 } }, \
    2.76 +	{ MODKEY|ControlMask,		XK_3,		{ toggleview },		{ .i = 2 } }, \
    2.77 +	{ MODKEY|ControlMask,		XK_4,		{ toggleview },		{ .i = 3 } }, \
    2.78 +	{ MODKEY|ControlMask,		XK_5,		{ toggleview },		{ .i = 4 } }, \
    2.79 +	{ MODKEY|ShiftMask,		XK_q,		{ quit },		{ 0 } }, \
    2.80  };
    2.81  
    2.82  /* Query class:instance:title for regex matching info with following command:
     3.1 --- a/event.c	Mon Nov 27 11:05:47 2006 +0100
     3.2 +++ b/event.c	Mon Nov 27 13:21:38 2006 +0100
     3.3 @@ -11,7 +11,7 @@
     3.4  typedef struct {
     3.5  	unsigned long mod;
     3.6  	KeySym keysym;
     3.7 -	void (*func)(Arg *arg);
     3.8 +	void (*func[NFUNCS])(Arg *arg);
     3.9  	Arg arg;
    3.10  } Key;
    3.11  
    3.12 @@ -245,7 +245,7 @@
    3.13  static void
    3.14  keypress(XEvent *e) {
    3.15  	static unsigned int len = sizeof key / sizeof key[0];
    3.16 -	unsigned int i;
    3.17 +	unsigned int i, j;
    3.18  	KeySym keysym;
    3.19  	XKeyEvent *ev = &e->xkey;
    3.20  
    3.21 @@ -254,8 +254,9 @@
    3.22  		if(keysym == key[i].keysym
    3.23  			&& CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
    3.24  		{
    3.25 -			if(key[i].func)
    3.26 -				key[i].func(&key[i].arg);
    3.27 +			for(j = 0; j < NFUNCS; j++)
    3.28 +				if(key[i].func[j])
    3.29 +					key[i].func[j](&key[i].arg);
    3.30  			return;
    3.31  		}
    3.32  	}