diff options
| author | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2023-01-01 16:40:22 -0500 |
|---|---|---|
| committer | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2023-01-01 16:40:22 -0500 |
| commit | ab116dd5ba0269105053f86ac8c61bd59d49f59f (patch) | |
| tree | 121df5028dca981af6ece17ed88e0eae13d0d98a /tabbed.c | |
| parent | 02fd939c0b1cbba5de57ead27449bb71bc959f65 (diff) | |
| download | tabbed-ab116dd5ba0269105053f86ac8c61bd59d49f59f.tar.gz | |
KeyRelease, Autohide, and config updates
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); |