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