annotate kb.c @ 31:386649deb651

before leaning things up
author Anselm R. Garbe <garbeam@wmii.de>
date Thu, 13 Jul 2006 01:04:38 +0200
parents 8ad86d0a6a53
children 082c75b937b5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1 /*
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
3 * See LICENSE file for license details.
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
4 */
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
5
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
6 #include "wm.h"
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
7
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
8 #include <X11/keysym.h>
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
9
31
386649deb651 before leaning things up
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
10 /********** CUSTOMIZE **********/
386649deb651 before leaning things up
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
11
386649deb651 before leaning things up
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
12 char *cmdterm[] = {
29
8ad86d0a6a53 added gravity stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 28
diff changeset
13 "aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn",
31
386649deb651 before leaning things up
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
14 "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL
14
5c078b66347b added bar event timer
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
15 };
5c078b66347b added bar event timer
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
16
31
386649deb651 before leaning things up
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
17 char *cmdproglist[] = {
27
f96fb3fd8203 added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents: 23
diff changeset
18 "sh", "-c", "exec `ls -lL /bin /sbin /usr/bin /usr/local/bin 2>/dev/null "
f96fb3fd8203 added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents: 23
diff changeset
19 "| awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | gridmenu`", 0
14
5c078b66347b added bar event timer
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
20 };
5c078b66347b added bar event timer
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
21
8
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
22 static Key key[] = {
31
386649deb651 before leaning things up
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
23 { Mod1Mask, XK_Return, run, cmdterm },
386649deb651 before leaning things up
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
24 { Mod1Mask, XK_p, run, cmdproglist},
27
f96fb3fd8203 added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents: 23
diff changeset
25 { Mod1Mask, XK_k, sel, "prev" },
f96fb3fd8203 added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents: 23
diff changeset
26 { Mod1Mask, XK_j, sel, "next" },
31
386649deb651 before leaning things up
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
27 { Mod1Mask, XK_g, grid, NULL },
386649deb651 before leaning things up
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
28 { Mod1Mask, XK_f, floating, NULL },
28
3dceb132082d added max
Anselm R. Garbe <garbeam@wmii.de>
parents: 27
diff changeset
29 { Mod1Mask, XK_m, max, NULL },
27
f96fb3fd8203 added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents: 23
diff changeset
30 { Mod1Mask | ShiftMask, XK_c, kill, NULL },
f96fb3fd8203 added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents: 23
diff changeset
31 { Mod1Mask | ShiftMask, XK_q, quit, NULL },
8
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
32 };
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
33
31
386649deb651 before leaning things up
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
34 /********** CUSTOMIZE **********/
386649deb651 before leaning things up
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
35
8
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
36 void
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
37 update_keys()
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
38 {
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
39 unsigned int i, len;
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
40 KeyCode code;
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
41
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
42 len = sizeof(key) / sizeof(key[0]);
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
43 for(i = 0; i < len; i++) {
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
44 code = XKeysymToKeycode(dpy, key[i].keysym);
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
45 XUngrabKey(dpy, code, key[i].mod, root);
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
46 XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
47 }
7066ff2fe8bc added key handling
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
48 }
9
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
49
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
50 void
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
51 keypress(XEvent *e)
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
52 {
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
53 XKeyEvent *ev = &e->xkey;
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
54 unsigned int i, len;
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
55 KeySym keysym;
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
56
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
57 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
58 len = sizeof(key) / sizeof(key[0]);
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
59 for(i = 0; i < len; i++)
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
60 if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
61 if(key[i].func)
14
5c078b66347b added bar event timer
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
62 key[i].func(key[i].aux);
9
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
63 return;
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
64 }
d567f430a81d fixed several stuff (gridwm gets better and better)
Anselm R. Garbe <garbeam@wmii.de>
parents: 8
diff changeset
65 }