static void maprequest(XEvent *e);
static void propertynotify(XEvent *e);
static void unmapnotify(XEvent *e);
-static void grabkeys(void);
static unsigned int idxoftag(const char *tag);
static void floating(void); /* default floating layout */
static void applyrules(Client *c);
KEYS
unsigned int len = sizeof keys / sizeof keys[0];
unsigned int i;
+ KeyCode code;
KeySym keysym;
- XKeyEvent *ev = &e->xkey;
-
+ XKeyEvent *ev;
+
+ if(!e) { /* grabkeys */
+ XUngrabKey(dpy, AnyKey, AnyModifier, root);
+ for(i = 0; i < len; i++) {
+ code = XKeysymToKeycode(dpy, keys[i].keysym);
+ XGrabKey(dpy, code, keys[i].mod, root, True,
+ GrabModeAsync, GrabModeAsync);
+ XGrabKey(dpy, code, keys[i].mod | LockMask, root, True,
+ GrabModeAsync, GrabModeAsync);
+ XGrabKey(dpy, code, keys[i].mod | numlockmask, root, True,
+ GrabModeAsync, GrabModeAsync);
+ XGrabKey(dpy, code, keys[i].mod | numlockmask | LockMask, root, True,
+ GrabModeAsync, GrabModeAsync);
+ }
+ return;
+ }
+ ev = &e->xkey;
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
for(i = 0; i < len; i++)
if(keysym == keys[i].keysym
XRefreshKeyboardMapping(ev);
if(ev->request == MappingKeyboard)
- grabkeys();
+ keypress(NULL);
}
static void
unmanage(c);
}
-static void
-grabkeys(void) {
- KEYS
- unsigned int len = sizeof keys / sizeof keys[0];
- unsigned int i;
- KeyCode code;
-
- XUngrabKey(dpy, AnyKey, AnyModifier, root);
- for(i = 0; i < len; i++) {
- code = XKeysymToKeycode(dpy, keys[i].keysym);
- XGrabKey(dpy, code, keys[i].mod, root, True,
- GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy, code, keys[i].mod | LockMask, root, True,
- GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy, code, keys[i].mod | numlockmask, root, True,
- GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy, code, keys[i].mod | numlockmask | LockMask, root, True,
- GrabModeAsync, GrabModeAsync);
- }
-}
-
static unsigned int
idxoftag(const char *tag) {
unsigned int i;
wa.cursor = cursor[CurNormal];
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
XSelectInput(dpy, root, wa.event_mask);
- grabkeys();
+ keypress(NULL); /* grabkeys */
compileregs();
for(ntags = 0; tags[ntags]; ntags++);
seltags = emallocz(sizeof(Bool) * ntags);