dwm

my heavily-patched and customized dwm build
git clone git://git.kocotian.pl/dwm.git
Log | Files | Refs | README | LICENSE

commit 24d70a762fcc459a8f5f8a8db658ccdf5bacea13
parent 410c4ec0f1c9996fcdf1c67b74ddba74a9c5ad66
Author: kocotian <kocotian@kocotian.pl>
Date:   Sat, 20 Mar 2021 13:39:55 +0100

Undo "vi-keys" normal mode (that was a fucking drama)

Diffstat:
Mconfig.def.h | 20--------------------
Mconfig.mk | 2+-
Mdwm.c | 74++++++++++----------------------------------------------------------------
3 files changed, 11 insertions(+), 85 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -180,8 +180,6 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_y, spawn, SHCMD("ytdlclip") }, { MODKEY|ControlMask, XK_y, spawn, SHCMD("youtube-viewer") }, - { MODKEY, XK_i, spawn, SHCMD("") }, - { MODKEY, XK_o, incnmaster, {.i = +1 } }, { MODKEY|ShiftMask, XK_o, incnmaster, {.i = -1 } }, { MODKEY, XK_p, spawn, SHCMD("mpc toggle") }, @@ -254,9 +252,6 @@ static Key keys[] = { { MODKEY, XK_Delete, spawn, SHCMD("dmenurecord kill") }, { MODKEY, XK_Scroll_Lock, spawn, SHCMD("killall screenkey || screenkey &") }, - { MODKEY, XK_Escape, vinormal, {.i = 1} }, - { MODKEY, XK_backslash, vinormal, {.i = 1} }, - { MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, TAGKEYS( XK_1, 0) @@ -270,21 +265,6 @@ static Key keys[] = { TAGKEYS( XK_9, 8) }; -static Key vikeys[] = { - { 0, XK_i, vinormal, {.i = 0} }, - - { 0, XK_j, xkeypress, {.ui = XK_Down} }, - { 0, XK_k, xkeypress, {.ui = XK_Up} }, - { 0, XK_h, xkeypress, {.ui = XK_Left} }, - { 0, XK_l, xkeypress, {.ui = XK_Right} }, - - { 0, XK_o, delayspawn, SHCMD("xdotool key End Return") }, - { ShiftMask, XK_o, delayspawn, SHCMD("xdotool keyup Shift; xdotool key Home Return Up; xdotool keydown Shift") }, - - { 0, XK_p, delayspawn, SHCMD("xdotool keyup Shift; xdotool type i\"$(xclip -selection primary -o)\"; xdotool keydown Shift") }, - { ShiftMask, XK_p, delayspawn, SHCMD("xdotool keyup Shift; xdotool type i\"$(xclip -selection clipboard -o)\"; xdotool keydown Shift") }, -}; - /* button definitions */ /* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ static Button buttons[] = { diff --git a/config.mk b/config.mk @@ -25,7 +25,7 @@ FREETYPEINC = /usr/include/freetype2 # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb \ - -lxcb -lxcb-res ${KVMLIB} -lXtst + -lxcb -lxcb-res ${KVMLIB} # flags CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}${BUILDNAME}\" ${XINERAMAFLAGS} diff --git a/dwm.c b/dwm.c @@ -42,7 +42,6 @@ #include <X11/Xft/Xft.h> #include <X11/Xlib-xcb.h> #include <xcb/res.h> -#include <X11/extensions/XTest.h> #ifdef __OpenBSD__ #include <sys/sysctl.h> #include <kvm.h> @@ -64,7 +63,6 @@ #define HEIGHT(X) ((X)->h + 2 * (X)->bw) #define TAGMASK ((1 << LENGTH(tags)) - 1) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) -#define DELAY 100000 /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ @@ -220,7 +218,6 @@ static void grabbuttons(Client *c, int focused); static void grabkeys(void); static void incnmaster(const Arg *arg); static void keypress(XEvent *e); -static void xkeypress(const Arg *arg); static void killclient(const Arg *arg); static void manage(Window w, XWindowAttributes *wa); static void mappingnotify(XEvent *e); @@ -265,8 +262,6 @@ static void sigdwmblocks(const Arg *arg); static void sighup(int unused); static void sigterm(int unused); static void spawn(const Arg *arg); -static void delayspawn(const Arg *arg); -static void redelayspawn(const Arg *arg); static void swaptags(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); @@ -291,7 +286,6 @@ static void updatetitle(Client *c); static void updatewindowtype(Client *c); static void updatewmhints(Client *c); static void view(const Arg *arg); -static void vinormal(const Arg *arg); static Client *wintoclient(Window w); static Monitor *wintomon(Window w); static int xerror(Display *dpy, XErrorEvent *ee); @@ -318,7 +312,6 @@ static int bh, blw = 0; /* bar geometry */ static int lrpad; /* sum of left and right padding for text */ static int (*xerrorxlib)(Display *, XErrorEvent *); static unsigned int numlockmask = 0; -static unsigned int vinormalmode = 0; static void (*handler[LASTEvent]) (XEvent *) = { [ButtonPress] = buttonpress, [ClientMessage] = clientmessage, @@ -1098,13 +1091,6 @@ drawbar(Monitor *m) } x = 0; - if (vinormalmode) { - w = blw = TEXTW("--- NORMAL MODE ---"); - drw_setscheme(drw, scheme[SchemeTagLnSel]); - drw_rect(drw, x + 1, 0, w - 2, 2, 1, 1); - drw_setscheme(drw, scheme[SchemeTagsNorm]); - x = drw_text(drw, x, 2, w, dbh, lrpad / 2, "--- NORMAL MODE ---", 0); - } for (i = 0; i < LENGTH(tags); i++) { w = TEXTW(tags[i]); @@ -1433,19 +1419,11 @@ grabkeys(void) KeyCode code; XUngrabKey(dpy, AnyKey, AnyModifier, root); - if (vinormalmode) { - for (i = 0; i < LENGTH(vikeys); i++) - if ((code = XKeysymToKeycode(dpy, vikeys[i].keysym))) - for (j = 0; j < LENGTH(modifiers); j++) - XGrabKey(dpy, code, vikeys[i].mod | modifiers[j], root, - True, GrabModeAsync, GrabModeAsync); - } else { - for (i = 0; i < LENGTH(keys); i++) - if ((code = XKeysymToKeycode(dpy, keys[i].keysym))) - for (j = 0; j < LENGTH(modifiers); j++) - XGrabKey(dpy, code, keys[i].mod | modifiers[j], root, - True, GrabModeAsync, GrabModeAsync); - } + for (i = 0; i < LENGTH(keys); i++) + if ((code = XKeysymToKeycode(dpy, keys[i].keysym))) + for (j = 0; j < LENGTH(modifiers); j++) + XGrabKey(dpy, code, keys[i].mod | modifiers[j], root, + True, GrabModeAsync, GrabModeAsync); } } @@ -1477,29 +1455,11 @@ keypress(XEvent *e) ev = &e->xkey; keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); - if (vinormalmode) { - for (i = 0; i < LENGTH(vikeys); i++) { - if (keysym == vikeys[i].keysym - && CLEANMASK(vikeys[i].mod) == CLEANMASK(ev->state) - && vikeys[i].func) - vikeys[i].func(&(vikeys[i].arg)); - } - } else { - for (i = 0; i < LENGTH(keys); i++) { - if (keysym == keys[i].keysym - && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) - && keys[i].func) - keys[i].func(&(keys[i].arg)); - } - } -} - -void -xkeypress(const Arg *arg) -{ - usleep(DELAY); - XTestFakeKeyEvent(dpy, XKeysymToKeycode(dpy, arg->ui), 1, CurrentTime); - XTestFakeKeyEvent(dpy, XKeysymToKeycode(dpy, arg->ui), 0, CurrentTime); + for (i = 0; i < LENGTH(keys); i++) + if (keysym == keys[i].keysym + && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) + && keys[i].func) + keys[i].func(&(keys[i].arg)); } void @@ -2560,13 +2520,6 @@ spawn(const Arg *arg) } void -delayspawn(const Arg *arg) -{ - usleep(DELAY); - spawn(arg); -} - -void swaptags(const Arg *arg) { unsigned int newtag = arg->ui & TAGMASK; @@ -3145,13 +3098,6 @@ view(const Arg *arg) arrange(selmon); } -void -vinormal(const Arg *arg) -{ - vinormalmode = arg->i; - grabkeys(); -} - pid_t winpid(Window w) {