My configuration of sxmo fork of suckless dwm.

git clone git://watertao.xyz/programs/sxmo-dwm.git

commit 4ae374e2cfb5cf43bcdacbc1e5e6833fd071a6e0
parent b4ef3d1e7bc52dc51b44f968b56224c54b8dbc82
Author: Willow Barraco <contact@willowbarraco.fr>
Date:   Thu, 16 Feb 2023 11:34:35 +0100

Delete multikey patch

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Peter John Hartman <peterjohnhartman@gmail.com>

Diffstat:
Mconfig.def.h | 105+++++++++++++++++++++++++++++++++++++------------------------------------------
Mdwm.c | 95+------------------------------------------------------------------------------
2 files changed, 50 insertions(+), 150 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -67,9 +67,9 @@ static const Layout layouts[] = { /* key definitions */ #define MODKEY Mod4Mask #define TAGKEYS(KEY,TAG) \ - {0, MODKEY, KEY, view, {.ui = 1 << TAG} }, \ - {0, MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ - {0, MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, + { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ + { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } @@ -81,81 +81,74 @@ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, #include <X11/XF86keysym.h> static Key keys[] = { /* PP */ - {1, 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("sxmo_hook_inputhandler.sh volup_one") }, - {2, 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("sxmo_hook_inputhandler.sh volup_two") }, - {3, 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("sxmo_hook_inputhandler.sh volup_three") }, - {1, 0, XF86XK_AudioLowerVolume, spawn, SHCMD("sxmo_hook_inputhandler.sh voldown_one") }, - {2, 0, XF86XK_AudioLowerVolume, spawn, SHCMD("sxmo_hook_inputhandler.sh voldown_two") }, - {3, 0, XF86XK_AudioLowerVolume, spawn, SHCMD("sxmo_hook_inputhandler.sh voldown_three") }, - //{3, 0, XF86XK_AudioLowerVolume, killclient, {0} }, - - {1, 0, XF86XK_PowerOff, spawn, SHCMD("sxmo_hook_inputhandler.sh powerbutton_one") }, - {2, 0, XF86XK_PowerOff, spawn, SHCMD("sxmo_hook_inputhandler.sh powerbutton_two") }, - {3, 0, XF86XK_PowerOff, spawn, SHCMD("sxmo_hook_inputhandler.sh powerbutton_three") }, + { 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("sxmo_hook_inputhandler.sh volup_one") }, + { 0, XF86XK_AudioLowerVolume, spawn, SHCMD("sxmo_hook_inputhandler.sh voldown_one") }, + + { 0, XF86XK_PowerOff, spawn, SHCMD("sxmo_hook_inputhandler.sh powerbutton_one") }, /* Used by scripts via xdotool */ - {0, MODKEY|ShiftMask, XK_e, shiftview, {.i = -1} }, - {0, MODKEY|ShiftMask, XK_r, shiftview, {.i = +1} }, - {0, MODKEY, XK_e, clienttagpush, {.i = -1} }, - {0, MODKEY, XK_r, clienttagpush, {.i = +1} }, + { MODKEY|ShiftMask, XK_e, shiftview, {.i = -1} }, + { MODKEY|ShiftMask, XK_r, shiftview, {.i = +1} }, + { MODKEY, XK_e, clienttagpush, {.i = -1} }, + { MODKEY, XK_r, clienttagpush, {.i = +1} }, /* PBP */ - { 0, MODKEY, XK_p, spawn, SHCMD("sxmo_appmenu.sh") }, - { 0, MODKEY, XK_d, spawn, SHCMD("sxmo_files.sh") }, + { MODKEY, XK_p, spawn, SHCMD("sxmo_appmenu.sh") }, + { MODKEY, XK_d, spawn, SHCMD("sxmo_files.sh") }, - { 0, MODKEY|ShiftMask, XK_Return, spawn, SHCMD("st") }, - { 0, MODKEY, XK_b, togglebar, {0} }, - { 0, MODKEY, XK_j, focusstack, {.i = +1 } }, - { 0, MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY|ShiftMask, XK_Return, spawn, SHCMD("st") }, + { MODKEY, XK_b, togglebar, {0} }, + { MODKEY, XK_j, focusstack, {.i = +1 } }, + { MODKEY, XK_k, focusstack, {.i = -1 } }, - { 0, MODKEY|ShiftMask, XK_j, pushdown, {.i = +1 } }, - { 0, MODKEY|ShiftMask, XK_k, pushup, {.i = -1 } }, + { MODKEY|ShiftMask, XK_j, pushdown, {.i = +1 } }, + { MODKEY|ShiftMask, XK_k, pushup, {.i = -1 } }, - { 0, MODKEY, XK_x, inplacerotate, {.i = +2 } }, + { MODKEY, XK_x, inplacerotate, {.i = +2 } }, - { 0, 0, XF86XK_MonBrightnessUp, spawn, SHCMD("sxmo_brightness.sh up") }, - { 0, 0, XF86XK_MonBrightnessDown, spawn, SHCMD("sxmo_brightness.sh down") }, - { 0, MODKEY|ShiftMask, XK_Down, spawn, SHCMD("sxmo_audio.sh vol down") }, - { 0, MODKEY|ShiftMask, XK_Up, spawn, SHCMD("sxmo_audio.sh vol up") }, + { 0, XF86XK_MonBrightnessUp, spawn, SHCMD("sxmo_brightness.sh up") }, + { 0, XF86XK_MonBrightnessDown, spawn, SHCMD("sxmo_brightness.sh down") }, + { MODKEY|ShiftMask, XK_Down, spawn, SHCMD("sxmo_audio.sh vol down") }, + { MODKEY|ShiftMask, XK_Up, spawn, SHCMD("sxmo_audio.sh vol up") }, - { 0, MODKEY, XK_i, incnmaster, {.i = +1 } }, - { 0, MODKEY, XK_o, incnmaster, {.i = -1 } }, - { 0, MODKEY, XK_h, setmfact, {.f = -0.05} }, - { 0, MODKEY, XK_l, setmfact, {.f = +0.05} }, - { 0, MODKEY, XK_Return, zoom, {0} }, - { 0, MODKEY, XK_Tab, view, {0} }, - { 0, MODKEY|ShiftMask, XK_c, killclient, {0} }, - { 0, MODKEY|ShiftMask, XK_q, killclient, {0} }, + { MODKEY, XK_i, incnmaster, {.i = +1 } }, + { MODKEY, XK_o, incnmaster, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY, XK_Return, zoom, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY|ShiftMask, XK_c, killclient, {0} }, + { MODKEY|ShiftMask, XK_q, killclient, {0} }, - { 0, MODKEY|ShiftMask, XK_q, killclient, {0} }, + { MODKEY|ShiftMask, XK_q, killclient, {0} }, - { 0, MODKEY, XK_semicolon, switchcol, {0} }, + { MODKEY, XK_semicolon, switchcol, {0} }, - { 1, MODKEY, XK_s, transfer, {0} }, - { 2, MODKEY, XK_s, transferall, {0} }, + { MODKEY, XK_s, transfer, {0} }, + { MODKEY, XK_s, transferall, {0} }, /* monocle */ - { 0, MODKEY, XK_m, setlayout, {.v = &layouts[3]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[3]} }, /* tile */ - { 0, MODKEY, XK_slash, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_slash, setlayout, {.v = &layouts[1]} }, /* bstack */ - { 0, MODKEY|ShiftMask, XK_slash, setlayout, {.v = &layouts[0]} }, + { MODKEY|ShiftMask, XK_slash, setlayout, {.v = &layouts[0]} }, - { 0, MODKEY, XK_f, togglefloating, {0} }, - { 0, MODKEY|ShiftMask, XK_f, unfloatvisible, {0} }, + { MODKEY, XK_f, togglefloating, {0} }, + { MODKEY|ShiftMask, XK_f, unfloatvisible, {0} }, /* cycle through the layouts in ppcyclelayouts */ - { 0, MODKEY, XK_space, cyclelayout, {.i = +1} }, + { MODKEY, XK_space, cyclelayout, {.i = +1} }, - { 0, MODKEY|ShiftMask, XK_space, togglefloating, {0} }, - { 0, MODKEY, XK_0, view, {.ui = ~0 } }, - { 0, MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, - { 0, MODKEY, XK_comma, focusmon, {.i = -1 } }, - { 0, MODKEY, XK_period, focusmon, {.i = +1 } }, - { 0, MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, - { 0, MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) diff --git a/dwm.c b/dwm.c @@ -20,7 +20,6 @@ * * To understand everything else, start reading main(). */ -#include <time.h> #include <errno.h> #include <locale.h> #include <signal.h> @@ -108,7 +107,6 @@ struct Client { }; typedef struct { - unsigned int npresses; unsigned int mod; KeySym keysym; void (*func)(const Arg *); @@ -193,7 +191,6 @@ static void grabkeys(void); static void incnmaster(const Arg *arg); static void inplacerotate(const Arg *arg); static void keypress(XEvent *e); -static void keyrelease(XEvent *e); static void killclient(const Arg *arg); static void manage(Window w, XWindowAttributes *wa); static void mappingnotify(XEvent *e); @@ -289,14 +286,12 @@ static void (*handler[LASTEvent]) (XEvent *) = { [Expose] = expose, [FocusIn] = focusin, [KeyPress] = keypress, - [KeyRelease] = keyrelease, [MappingNotify] = mappingnotify, [MapRequest] = maprequest, //[MotionNotify] = motionnotify, [PropertyNotify] = propertynotify, [UnmapNotify] = unmapnotify }; -static Atom timeratom; static Atom wmatom[WMLast], netatom[NetLast]; static int running = 1; static Cur *cursor[CurLast]; @@ -309,13 +304,6 @@ static Window root, wmcheckwin; /* Empty arrays to be filled from command line, Xresources, and defaults, in decreasing order of precedence */ static char *colors[4][3]; /* 4 schemes, 3 colors each */ -int keyhold_ms_threshold = 500; -int keypress_ms_threshold = 300; - -static int multikeypendingindex = -1; -timer_t multikeypendingtimer; -static int multikeyup = 1; - static xcb_connection_t *xcon; /* configuration, allows nested code to access above variables */ @@ -772,7 +760,6 @@ clientmessage(XEvent *e) XClientMessageEvent *cme = &e->xclient; Client *c = wintoclient(cme->window); - if (cme->message_type == timeratom) { keypresstimerdonesync(cme->data.s[0]); return; } if (!c) return; if (cme->message_type == netatom[NetWMState]) { @@ -1275,58 +1262,6 @@ iswide() { return sw > 1000 ? 1 : 0; } -void keypresstimerdonesync(int idx) { - int i, maxidx; - - if (keys[idx].npresses == 1 && !multikeyup) { - // Dispatch hold key - maxidx = -1; - for (i = 0; i < LENGTH(keys); i++) - if (keys[i].keysym == keys[idx].keysym) maxidx = i; - if (maxidx != -1) - keypresstimerdispatch(keyhold_ms_threshold - keypress_ms_threshold, maxidx); - } else if (keys[idx].func) { - // Run the actual keys' fn - keys[idx].func(&(keys[idx].arg)); - multikeypendingindex = -1; - } -} - -void keypresstimerdone(union sigval timer_data) -{ - XEvent ev; - memset(&ev, 0, sizeof ev); - ev.xclient.type = ClientMessage; - ev.xclient.window = root; - ev.xclient.message_type = timeratom; - ev.xclient.format = 16; - ev.xclient.data.s[0] = ((short) timer_data.sival_int); - XSendEvent(dpy, root, False, SubstructureRedirectMask, &ev); - XSync(dpy, False); -} - -void keypresstimerdispatch(int msduration, int data) -{ - struct sigevent timer_signal_event; - struct itimerspec timer_period; - static int multikeypendingtimer_created = 0; - // Clear out the old timer if any set,and dispatch new timer - if (multikeypendingtimer_created) { - timer_delete(multikeypendingtimer); - } - timer_signal_event.sigev_notify = SIGEV_THREAD; - timer_signal_event.sigev_notify_function = keypresstimerdone; - timer_signal_event.sigev_value.sival_int = data; - timer_signal_event.sigev_notify_attributes = NULL; - timer_create(CLOCK_MONOTONIC, &timer_signal_event, &multikeypendingtimer); - multikeypendingtimer_created = 1; - timer_period.it_value.tv_sec = 0; - timer_period.it_value.tv_nsec = msduration * 1000000; - timer_period.it_interval.tv_sec = 0; - timer_period.it_interval.tv_nsec = 0; - timer_settime(multikeypendingtimer, 0, &timer_period, NULL); -} - void keypress(XEvent *e) { @@ -1340,33 +1275,12 @@ keypress(XEvent *e) if (keysym == keys[i].keysym && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) && keys[i].func) { - // E.g. Normal functionality case - npresses 0 - if (keys[i].npresses == 0) { - keys[i].func(&(keys[i].arg)); - break; - } - - // Multikey functionality - find index of key, set global, & dispatch - if ( - (multikeypendingindex == -1 && multikeyup && keys[i].npresses == 1) || - (multikeypendingindex != -1 && keys[multikeypendingindex].npresses + 1 == keys[i].npresses) - ) { - multikeyup = 0; - multikeypendingindex = i; - keypresstimerdispatch(keypress_ms_threshold, i); - break; - } + keys[i].func(&(keys[i].arg)); } } } void -keyrelease(XEvent *e) -{ - multikeyup = 1; -} - -void killclient(const Arg *arg) { if (!selmon->sel) @@ -1938,11 +1852,6 @@ setup(void) } } - if (getenv("SXMO_THRESHOLD")) { - keypress_ms_threshold = atoi(getenv("SXMO_THRESHOLD")); - keyhold_ms_threshold = keypress_ms_threshold + 300; // To match sway input delay multikey config - } - if (!drw_font_create(drw, font)) die("no fonts could be loaded."); lrpad = drw->font->h; @@ -1950,7 +1859,6 @@ setup(void) updategeom(); /* init atoms */ utf8string = XInternAtom(dpy, "UTF8_STRING", False); - timeratom = XInternAtom(dpy, "TIMER", False); wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); @@ -2732,7 +2640,6 @@ main(int argc, char *argv[]) fputs("warning: no locale support\n", stderr); if (!(dpy = XOpenDisplay(NULL))) die("dwm: cannot open display"); - XkbSetDetectableAutoRepeat(dpy, True, NULL); if (!(xcon = XGetXCBConnection(dpy))) die("dwm: cannot get xcb connection\n"); checkotherwm();