dwm-meillo

view key.c @ 12:a2b399582afe

new stuff
author Anselm R. Garbe <garbeam@wmii.de>
date Tue, 11 Jul 2006 14:53:22 +0200
parents 7066ff2fe8bc
children 5c078b66347b
line source
1 /*
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
4 */
6 #include "wm.h"
8 #include <X11/keysym.h>
10 static Key key[] = {
11 KEYS
12 };
14 void
15 update_keys()
16 {
17 unsigned int i, len;
18 KeyCode code;
20 len = sizeof(key) / sizeof(key[0]);
21 for(i = 0; i < len; i++) {
22 code = XKeysymToKeycode(dpy, key[i].keysym);
23 XUngrabKey(dpy, code, key[i].mod, root);
24 XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
25 }
26 }
28 void
29 keypress(XEvent *e)
30 {
31 XKeyEvent *ev = &e->xkey;
32 unsigned int i, len;
33 KeySym keysym;
35 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
36 len = sizeof(key) / sizeof(key[0]);
37 for(i = 0; i < len; i++)
38 if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
39 if(key[i].func)
40 key[i].func(key[i].arg);
41 return;
42 }
43 }