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 | |
| parent | 02fd939c0b1cbba5de57ead27449bb71bc959f65 (diff) | |
| download | tabbed-ab116dd5ba0269105053f86ac8c61bd59d49f59f.tar.gz | |
KeyRelease, Autohide, and config updates
| -rw-r--r-- | config.def.h | 35 | ||||
| -rw-r--r-- | tabbed.c | 30 |
2 files changed, 51 insertions, 14 deletions
diff --git a/config.def.h b/config.def.h index ec85d23..45ebbfa 100644 --- a/config.def.h +++ b/config.def.h @@ -39,23 +39,23 @@ static Bool npisrelative = False; ResourcePref resources[] = { { "font", STRING, &font }, { "color0", STRING, &normbgcolor }, - { "color4", STRING, &normfgcolor }, + { "color7", STRING, &normfgcolor }, { "color4", STRING, &selbgcolor }, - { "color7", STRING, &selfgcolor }, - { "color2", STRING, &urgbgcolor }, - { "color3", STRING, &urgfgcolor }, + { "color15", STRING, &selfgcolor }, + { "color3", STRING, &urgbgcolor }, + { "color15", STRING, &urgfgcolor }, }; -#define MODKEY ControlMask +#define MODKEY ControlMask|Mod1Mask static const Key keys[] = { /* modifier key function argument */ - { MODKEY|ShiftMask, XK_Return, focusonce, { 0 } }, - { MODKEY|ShiftMask, XK_Return, spawn, { 0 } }, + { MODKEY, XK_Return, focusonce, { 0 } }, + { MODKEY, XK_Return, spawn, { 0 } }, - { MODKEY|ShiftMask, XK_l, rotate, { .i = +1 } }, - { MODKEY|ShiftMask, XK_h, rotate, { .i = -1 } }, - { MODKEY|ShiftMask, XK_j, movetab, { .i = -1 } }, - { MODKEY|ShiftMask, XK_k, movetab, { .i = +1 } }, + { MODKEY, XK_l, rotate, { .i = +1 } }, + { MODKEY, XK_h, rotate, { .i = -1 } }, + { MODKEY|ShiftMask, XK_h, movetab, { .i = -1 } }, + { MODKEY|ShiftMask, XK_l, movetab, { .i = +1 } }, { MODKEY, XK_Tab, rotate, { .i = 0 } }, { MODKEY, XK_grave, spawn, SETPROP("_TABBED_SELECT_TAB") }, @@ -71,9 +71,18 @@ static const Key keys[] = { { MODKEY, XK_0, move, { .i = 9 } }, { MODKEY, XK_q, killclient, { 0 } }, - { MODKEY, XK_u, focusurgent, { 0 } }, { MODKEY|ShiftMask, XK_u, toggle, { .v = (void*) &urgentswitch } }, - { 0, XK_F11, fullscreen, { 0 } }, + + { ControlMask, XK_Alt_L, showbar, { .i = 1 } }, + { ControlMask, XK_Alt_R, showbar, { .i = 1 } }, +}; + +static Key keyreleases[] = { + /* modifier key function argument */ + { MODKEY, XK_Alt_L, showbar, { .i = 0 } }, + { MODKEY, XK_Alt_R, showbar, { .i = 0 } }, + { MODKEY, XK_Control_L, showbar, { .i = 0 } }, + { MODKEY, XK_Control_R, showbar, { .i = 0 } }, }; @@ -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); |