dwm-keypressrelease-6.0.diff (6698B)
1 diff -up dwm-6.0-clean/config.def.h dwm-6.0-patched/config.def.h 2 --- dwm-6.0-clean/config.def.h 2011-12-19 16:02:46.000000000 +0100 3 +++ dwm-6.0-patched/config.def.h 2014-02-28 22:21:05.254046315 +0100 4 @@ -37,10 +37,10 @@ static const Layout layouts[] = { 5 /* key definitions */ 6 #define MODKEY Mod1Mask 7 #define TAGKEYS(KEY,TAG) \ 8 - { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ 9 - { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ 10 - { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ 11 - { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, 12 + { KeyPress, MODKEY, KEY, view, {.ui = 1 << TAG} }, \ 13 + { KeyPress, MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ 14 + { KeyPress, MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ 15 + { KeyPress, MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, 16 17 /* helper for spawning shell commands in the pre dwm-5.0 fashion */ 18 #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } 19 @@ -50,30 +50,30 @@ static const char *dmenucmd[] = { "dmenu 20 static const char *termcmd[] = { "uxterm", NULL }; 21 22 static Key keys[] = { 23 - /* modifier key function argument */ 24 - { MODKEY, XK_p, spawn, {.v = dmenucmd } }, 25 - { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, 26 - { MODKEY, XK_b, togglebar, {0} }, 27 - { MODKEY, XK_j, focusstack, {.i = +1 } }, 28 - { MODKEY, XK_k, focusstack, {.i = -1 } }, 29 - { MODKEY, XK_i, incnmaster, {.i = +1 } }, 30 - { MODKEY, XK_d, incnmaster, {.i = -1 } }, 31 - { MODKEY, XK_h, setmfact, {.f = -0.05} }, 32 - { MODKEY, XK_l, setmfact, {.f = +0.05} }, 33 - { MODKEY, XK_Return, zoom, {0} }, 34 - { MODKEY, XK_Tab, view, {0} }, 35 - { MODKEY|ShiftMask, XK_c, killclient, {0} }, 36 - { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, 37 - { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, 38 - { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, 39 - { MODKEY, XK_space, setlayout, {0} }, 40 - { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, 41 - { MODKEY, XK_0, view, {.ui = ~0 } }, 42 - { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, 43 - { MODKEY, XK_comma, focusmon, {.i = -1 } }, 44 - { MODKEY, XK_period, focusmon, {.i = +1 } }, 45 - { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, 46 - { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, 47 + /* type modifier key function argument */ 48 + { KeyPress, MODKEY, XK_p, spawn, {.v = dmenucmd } }, 49 + { KeyPress, MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, 50 + { KeyPress, MODKEY, XK_b, togglebar, {0} }, 51 + { KeyPress, MODKEY, XK_j, focusstack, {.i = +1 } }, 52 + { KeyPress, MODKEY, XK_k, focusstack, {.i = -1 } }, 53 + { KeyPress, MODKEY, XK_i, incnmaster, {.i = +1 } }, 54 + { KeyPress, MODKEY, XK_d, incnmaster, {.i = -1 } }, 55 + { KeyPress, MODKEY, XK_h, setmfact, {.f = -0.05} }, 56 + { KeyPress, MODKEY, XK_l, setmfact, {.f = +0.05} }, 57 + { KeyPress, MODKEY, XK_Return, zoom, {0} }, 58 + { KeyPress, MODKEY, XK_Tab, view, {0} }, 59 + { KeyPress, MODKEY|ShiftMask, XK_c, killclient, {0} }, 60 + { KeyPress, MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, 61 + { KeyPress, MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, 62 + { KeyPress, MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, 63 + { KeyPress, MODKEY, XK_space, setlayout, {0} }, 64 + { KeyPress, MODKEY|ShiftMask, XK_space, togglefloating, {0} }, 65 + { KeyPress, MODKEY, XK_0, view, {.ui = ~0 } }, 66 + { KeyPress, MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, 67 + { KeyPress, MODKEY, XK_comma, focusmon, {.i = -1 } }, 68 + { KeyPress, MODKEY, XK_period, focusmon, {.i = +1 } }, 69 + { KeyPress, MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, 70 + { KeyPress, MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, 71 TAGKEYS( XK_1, 0) 72 TAGKEYS( XK_2, 1) 73 TAGKEYS( XK_3, 2) 74 @@ -83,7 +83,7 @@ static Key keys[] = { 75 TAGKEYS( XK_7, 6) 76 TAGKEYS( XK_8, 7) 77 TAGKEYS( XK_9, 8) 78 - { MODKEY|ShiftMask, XK_q, quit, {0} }, 79 + { KeyPress, MODKEY|ShiftMask, XK_q, quit, {0} }, 80 }; 81 82 /* button definitions */ 83 diff -up dwm-6.0-clean/dwm.c dwm-6.0-patched/dwm.c 84 --- dwm-6.0-clean/dwm.c 2011-12-19 16:02:46.000000000 +0100 85 +++ dwm-6.0-patched/dwm.c 2014-02-28 22:19:58.466047686 +0100 86 @@ -113,6 +113,7 @@ typedef struct { 87 } DC; /* draw context */ 88 89 typedef struct { 90 + int type; 91 unsigned int mod; 92 KeySym keysym; 93 void (*func)(const Arg *); 94 @@ -270,6 +271,7 @@ static void (*handler[LASTEvent]) (XEven 95 [Expose] = expose, 96 [FocusIn] = focusin, 97 [KeyPress] = keypress, 98 + [KeyRelease] = keypress, 99 [MappingNotify] = mappingnotify, 100 [MapRequest] = maprequest, 101 [MotionNotify] = motionnotify, 102 @@ -1087,6 +1089,7 @@ keypress(XEvent *e) { 103 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); 104 for(i = 0; i < LENGTH(keys); i++) 105 if(keysym == keys[i].keysym 106 + && ev->type == keys[i].type 107 && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) 108 && keys[i].func) 109 keys[i].func(&(keys[i].arg));