comparison event.c @ 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 601842ee4484
children 732c58a3d92d
comparison
equal deleted inserted replaced
585:83807f4d18e9 586:c2ddd15b199e
9 /* static */ 9 /* static */
10 10
11 typedef struct { 11 typedef struct {
12 unsigned long mod; 12 unsigned long mod;
13 KeySym keysym; 13 KeySym keysym;
14 void (*func)(Arg *arg); 14 void (*func[NFUNCS])(Arg *arg);
15 Arg arg; 15 Arg arg;
16 } Key; 16 } Key;
17 17
18 KEYS 18 KEYS
19 19
243 } 243 }
244 244
245 static void 245 static void
246 keypress(XEvent *e) { 246 keypress(XEvent *e) {
247 static unsigned int len = sizeof key / sizeof key[0]; 247 static unsigned int len = sizeof key / sizeof key[0];
248 unsigned int i; 248 unsigned int i, j;
249 KeySym keysym; 249 KeySym keysym;
250 XKeyEvent *ev = &e->xkey; 250 XKeyEvent *ev = &e->xkey;
251 251
252 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); 252 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
253 for(i = 0; i < len; i++) { 253 for(i = 0; i < len; i++) {
254 if(keysym == key[i].keysym 254 if(keysym == key[i].keysym
255 && CLEANMASK(key[i].mod) == CLEANMASK(ev->state)) 255 && CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
256 { 256 {
257 if(key[i].func) 257 for(j = 0; j < NFUNCS; j++)
258 key[i].func(&key[i].arg); 258 if(key[i].func[j])
259 key[i].func[j](&key[i].arg);
259 return; 260 return;
260 } 261 }
261 } 262 }
262 } 263 }
263 264