commit 70ebeccfc5fd23cbd87296ff62e1d42547f9e5a5
Author: Ceryn <git_AT_ceryn.me>
Date: Mon Feb 17 04:20:28 2014 +0100
Added dwm patch keypressrelease.
diff --git a/dwm.suckless.org/patches/dwm-6.0-keypressrelease.diff b/dwm.suckless.org/patches/dwm-6.0-keypressrelease.diff
new file mode 100644
index 0000000..015e1a6
--- /dev/null
+++ b/dwm.suckless.org/patches/dwm-6.0-keypressrelease.diff
_AT_@ -0,0 +1,130 @@
+diff -up dwmvanilla/config.h dwmpatched/config.h
+--- dwmvanilla/config.h 2011-12-19 16:02:46.000000000 +0100
++++ dwmpatched/config.h 2014-02-15 02:34:25.503574829 +0100
+_AT_@ -37,10 +37,10 @@ static const Layout layouts[] = {
+ /* key definitions */
+ #define MODKEY Mod1Mask
+ #define TAGKEYS(KEY,TAG) \
+- { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
+- { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
+- { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
+- { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
++ { KeyPress, MODKEY, KEY, view, {.ui = 1 << TAG} }, \
++ { KeyPress, MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
++ { KeyPress, MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
++ { KeyPress, MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.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 } }
+_AT_@ -50,30 +50,30 @@ static const char *dmenucmd[] = { "dmenu
+ static const char *termcmd[] = { "uxterm", NULL };
+
+ static Key keys[] = {
+- /* modifier key function argument */
+- { MODKEY, XK_p, spawn, {.v = dmenucmd } },
+- { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
+- { MODKEY, XK_b, togglebar, {0} },
+- { MODKEY, XK_j, focusstack, {.i = +1 } },
+- { MODKEY, XK_k, focusstack, {.i = -1 } },
+- { MODKEY, XK_i, incnmaster, {.i = +1 } },
+- { MODKEY, XK_d, 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, XK_t, setlayout, {.v = &layouts[0]} },
+- { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
+- { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
+- { MODKEY, XK_space, setlayout, {0} },
+- { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+- { MODKEY, XK_0, view, {.ui = ~0 } },
+- { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
+- { 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 } },
++ /* type modifier key function argument */
++ { KeyPress, MODKEY, XK_p, spawn, {.v = dmenucmd } },
++ { KeyPress, MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
++ { KeyPress, MODKEY, XK_b, togglebar, {0} },
++ { KeyPress, MODKEY, XK_j, focusstack, {.i = +1 } },
++ { KeyPress, MODKEY, XK_k, focusstack, {.i = -1 } },
++ { KeyPress, MODKEY, XK_i, incnmaster, {.i = +1 } },
++ { KeyPress, MODKEY, XK_d, incnmaster, {.i = -1 } },
++ { KeyPress, MODKEY, XK_h, setmfact, {.f = -0.05} },
++ { KeyPress, MODKEY, XK_l, setmfact, {.f = +0.05} },
++ { KeyPress, MODKEY, XK_Return, zoom, {0} },
++ { KeyPress, MODKEY, XK_Tab, view, {0} },
++ { KeyPress, MODKEY|ShiftMask, XK_c, killclient, {0} },
++ { KeyPress, MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
++ { KeyPress, MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
++ { KeyPress, MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
++ { KeyPress, MODKEY, XK_space, setlayout, {0} },
++ { KeyPress, MODKEY|ShiftMask, XK_space, togglefloating, {0} },
++ { KeyPress, MODKEY, XK_0, view, {.ui = ~0 } },
++ { KeyPress, MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
++ { KeyPress, MODKEY, XK_comma, focusmon, {.i = -1 } },
++ { KeyPress, MODKEY, XK_period, focusmon, {.i = +1 } },
++ { KeyPress, MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
++ { KeyPress, MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+_AT_@ -83,7 +83,7 @@ static Key keys[] = {
+ TAGKEYS( XK_7, 6)
+ TAGKEYS( XK_8, 7)
+ TAGKEYS( XK_9, 8)
+- { MODKEY|ShiftMask, XK_q, quit, {0} },
++ { KeyPress, MODKEY|ShiftMask, XK_q, quit, {0} },
+ };
+
+ /* button definitions */
+Only in dwmpatched: dwm
+diff -up dwmvanilla/dwm.c dwmpatched/dwm.c
+--- dwmvanilla/dwm.c 2011-12-19 16:02:46.000000000 +0100
++++ dwmpatched/dwm.c 2014-02-15 02:39:19.967568786 +0100
+_AT_@ -113,6 +113,7 @@ typedef struct {
+ } DC; /* draw context */
+
+ typedef struct {
++ int type;
+ unsigned int mod;
+ KeySym keysym;
+ void (*func)(const Arg *);
+_AT_@ -194,7 +195,7 @@ static void grabbuttons(Client *c, Bool
+ static void grabkeys(void);
+ static void incnmaster(const Arg *arg);
+ static void initfont(const char *fontstr);
+-static void keypress(XEvent *e);
++static void keypressrelease(XEvent *e);
+ static void killclient(const Arg *arg);
+ static void manage(Window w, XWindowAttributes *wa);
+ static void mappingnotify(XEvent *e);
+_AT_@ -269,7 +270,8 @@ static void (*handler[LASTEvent]) (XEven
+ [EnterNotify] = enternotify,
+ [Expose] = expose,
+ [FocusIn] = focusin,
+- [KeyPress] = keypress,
++ [KeyPress] = keypressrelease,
++ [KeyRelease] = keypressrelease,
+ [MappingNotify] = mappingnotify,
+ [MapRequest] = maprequest,
+ [MotionNotify] = motionnotify,
+_AT_@ -1078,7 +1080,7 @@ isuniquegeom(XineramaScreenInfo *unique,
+ #endif /* XINERAMA */
+
+ void
+-keypress(XEvent *e) {
++keypressrelease(XEvent *e) {
+ unsigned int i;
+ KeySym keysym;
+ XKeyEvent *ev;
+_AT_@ -1087,6 +1089,7 @@ keypress(XEvent *e) {
+ keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
+ for(i = 0; i < LENGTH(keys); i++)
+ if(keysym == keys[i].keysym
++ && ev->type == keys[i].type
+ && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
+ && keys[i].func)
+ keys[i].func(&(keys[i].arg));
diff --git a/dwm.suckless.org/patches/keypressrelease.md b/dwm.suckless.org/patches/keypressrelease.md
new file mode 100644
index 0000000..5ae286c
--- /dev/null
+++ b/dwm.suckless.org/patches/keypressrelease.md
_AT_@ -0,0 +1,38 @@
+keypressrelease
+===
+
+Description
+---
+
+This patch lets you specify whether a key binding should be executed at the _KeyPress_ or _KeyRelease_ event.
+Executing on _KeyRelease_ fixes bugs such as `scrot -s` failing to execute from a key binding due to keys not being released in time[1][2].
+
+Note that the new parameter must be added to all non-standard key bindings manually after patching.
+
+Usage
+---
+A working `scrot -s` key binding:
+
+ static const char *scrot[] = { "scrot", "-s", NULL };
+ ...
+ { KeyRelease, 0, XK_Print, spawn, {.v = scrot } },
+
+Or to only display the bar while the toggle key is held down (requires that it is hidden to start with), add:
+
+ { KeyRelease, MODKEY, XK_b, togglebar, {0} },
+
+Download
+---
+
+ * [dwm-6.0-keypressrelease.diff](dwm-6.0-keypressrelease.diff)
+ * [dwm-6.0-keypressrelease.diff on GitHub](
https://github.com/Ceryn/patches/blob/master/dwm/dwm-6.0-keypressrelease.diff)
+
+Author
+------
+
+ * Niklas Høj <niklas at hoej dot me>
+
+---
+
+[1] Error produced: "giblib error: couldn't grab keyboard: Resource temporarily unavailable"
+[2] Old discussion thread: [
http://lists.suckless.org/dev/1108/9185.html]
Received on Mon Feb 17 2014 - 04:21:39 CET