[hackers] [dwm] removed grabkeys, not necessary

From: Anselm R. Garbe <garbeam_AT_gmail.com>
Date: Sat Sep 15 22:47:01 2007

changeset: 991:277c0e5bd0df
user: Anselm R. Garbe <garbeam_AT_gmail.com>
date: Sat Sep 15 22:31:24 2007 +0200
summary: removed grabkeys, not necessary

diff -r 70f6fcd100b7 -r 277c0e5bd0df dwm.c
--- a/dwm.c Sat Sep 15 22:25:27 2007 +0200
+++ b/dwm.c Sat Sep 15 22:31:24 2007 +0200
@@ -129,7 +129,6 @@ static void maprequest(XEvent *e);
 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);
@@ -1070,9 +1069,26 @@ keypress(XEvent *e) {
         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
@@ -1099,7 +1115,7 @@ mappingnotify(XEvent *e) {
 
         XRefreshKeyboardMapping(ev);
         if(ev->request == MappingKeyboard)
- grabkeys();
+ keypress(NULL);
 }
 
 static void
@@ -1150,27 +1166,6 @@ unmapnotify(XEvent *e) {
 
         if((c = getclient(ev->window)))
                 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
@@ -1546,7 +1541,7 @@ setup(void) {
         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);
Received on Sat Sep 15 2007 - 22:47:01 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:58:06 UTC