diff options
Diffstat (limited to 'tabbed.c')
| -rw-r--r-- | tabbed.c | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -129,6 +129,7 @@ static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); static void initfont(const char *fontstr); static Bool isprotodel(int c); static void keypress(const XEvent *e); +static void keyrelease(const XEvent *e); static void killclient(const Arg *arg); static void manage(Window win); static void maprequest(const XEvent *e); @@ -167,6 +168,7 @@ static void (*handler[LASTEvent]) (const XEvent *) = { [Expose] = expose, [FocusIn] = focusin, [KeyPress] = keypress, + [KeyRelease] = keyrelease, [MapRequest] = maprequest, [PropertyNotify] = propertynotify, }; @@ -722,6 +724,22 @@ keypress(const XEvent *e) } void +keyrelease(const XEvent *e) +{ + const XKeyEvent *ev = &e->xkey; + unsigned int i; + KeySym keysym; + + keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0, 0); + for (i = 0; i < LENGTH(keyreleases); i++) { + if (keysym == keyreleases[i].keysym && + CLEANMASK(keyreleases[i].mod) == CLEANMASK(ev->state) && + keyreleases[i].func) + keyreleases[i].func(&(keyreleases[i].arg)); + } +} + +void killclient(const Arg *arg) { XEvent ev; @@ -771,6 +789,16 @@ manage(Window w) } } + for (i = 0; i < LENGTH(keyreleases); i++) { + if ((code = XKeysymToKeycode(dpy, keyreleases[i].keysym))) { + for (j = 0; j < LENGTH(modifiers); j++) { + XGrabKey(dpy, code, keyreleases[i].mod | + modifiers[j], w, True, + GrabModeAsync, GrabModeAsync); + } + } + } + c = ecalloc(1, sizeof *c); c->win = w; @@ -1127,7 +1155,7 @@ setup(void) XMapRaised(dpy, win); XSelectInput(dpy, win, SubstructureNotifyMask | FocusChangeMask | ButtonPressMask | ExposureMask | KeyPressMask | - PropertyChangeMask | StructureNotifyMask | + KeyReleaseMask | PropertyChangeMask | StructureNotifyMask | SubstructureRedirectMask); xerrorxlib = XSetErrorHandler(xerror); |