Introduction
Introduction Statistics Contact Development Disclaimer Help
dwm-keychain-20200729-053e3a2.diff - sites - public wiki contents of suckless.o…
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dwm-keychain-20200729-053e3a2.diff (11441B)
---
1 From e6c2d5fdc6010a22d6cd74485cb0b3e74467d0da Mon Sep 17 00:00:00 2001
2 From: braunbearded <[email protected]>
3 Date: Wed, 29 Jul 2020 18:37:47 +0200
4 Subject: [PATCH 1/4] chain key bindings
5
6 ---
7 dwm.c | 34 +++++++++++++++++++++++++++++-----
8 1 file changed, 29 insertions(+), 5 deletions(-)
9
10 diff --git a/dwm.c b/dwm.c
11 index 9fd0286..7298c5e 100644
12 --- a/dwm.c
13 +++ b/dwm.c
14 @@ -101,6 +101,7 @@ struct Client {
15
16 typedef struct {
17 unsigned int mod;
18 + KeySym chain;
19 KeySym keysym;
20 void (*func)(const Arg *);
21 const Arg arg;
22 @@ -268,6 +269,7 @@ static Display *dpy;
23 static Drw *drw;
24 static Monitor *mons, *selmon;
25 static Window root, wmcheckwin;
26 +static KeySym keychain = -1;
27
28 /* configuration, allows nested code to access above variables */
29 #include "config.h"
30 @@ -954,13 +956,18 @@ grabkeys(void)
31 unsigned int i, j;
32 unsigned int modifiers[] = { 0, LockMask, numlockmask, …
33 KeyCode code;
34 + KeyCode chain;
35
36 XUngrabKey(dpy, AnyKey, AnyModifier, root);
37 for (i = 0; i < LENGTH(keys); i++)
38 - if ((code = XKeysymToKeycode(dpy, keys[i].keysy…
39 + if ((code = XKeysymToKeycode(dpy, keys[i].keysy…
40 + if (keys[i].chain != -1 &&
41 + ((chain = XKeysymToKeycode(dpy,…
42 + code = chain;
43 for (j = 0; j < LENGTH(modifiers); j++)
44 XGrabKey(dpy, code, keys[i].mod…
45 True, GrabModeAsync, Gr…
46 + }
47 }
48 }
49
50 @@ -989,14 +996,31 @@ keypress(XEvent *e)
51 unsigned int i;
52 KeySym keysym;
53 XKeyEvent *ev;
54 + int current = 0;
55
56 ev = &e->xkey;
57 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
58 - for (i = 0; i < LENGTH(keys); i++)
59 - if (keysym == keys[i].keysym
60 - && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
61 - && keys[i].func)
62 + for (i = 0; i < LENGTH(keys); i++) {
63 + if (keysym == keys[i].keysym && keys[i].chain == -1
64 + && CLEANMASK(keys[i].mod) == CLEANMASK(…
65 + && keys[i].func)
66 + keys[i].func(&(keys[i].arg));
67 + else if (keysym == keys[i].chain && keychain == -1
68 + && CLEANMASK(keys[i].mod) == CLEANMASK(…
69 + && keys[i].func) {
70 + current = 1;
71 + keychain = keysym;
72 + XGrabKey(dpy, AnyKey, AnyModifier, root, True, …
73 + GrabModeAsync);
74 + } else if (!current && keysym == keys[i].keysym
75 + && keys[i].chain == keychain
76 + && keys[i].func)
77 keys[i].func(&(keys[i].arg));
78 + }
79 + if (!current) {
80 + keychain = -1;
81 + grabkeys();
82 + }
83 }
84
85 void
86 --
87 2.28.0
88
89
90 From ad3d15cf7df3286d35728afef823c3163898e2db Mon Sep 17 00:00:00 2001
91 From: braunbearded <[email protected]>
92 Date: Wed, 29 Jul 2020 18:38:15 +0200
93 Subject: [PATCH 2/4] update default bindings
94
95 ---
96 config.def.h | 80 +++++++++++++++++++++++++++-------------------------
97 1 file changed, 41 insertions(+), 39 deletions(-)
98
99 diff --git a/config.def.h b/config.def.h
100 index 1c0b587..c7cab16 100644
101 --- a/config.def.h
102 +++ b/config.def.h
103 @@ -45,11 +45,11 @@ static const Layout layouts[] = {
104
105 /* key definitions */
106 #define MODKEY Mod1Mask
107 -#define TAGKEYS(KEY,TAG) \
108 - { MODKEY, KEY, view, {.ui …
109 - { MODKEY|ControlMask, KEY, toggleview, {.ui …
110 - { MODKEY|ShiftMask, KEY, tag, {.ui …
111 - { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui …
112 +#define TAGKEYS(CHAIN,KEY,TAG) \
113 + { MODKEY, CHAIN, KEY, view, …
114 + { MODKEY|ControlMask, CHAIN, KEY, toggleview,…
115 + { MODKEY|ShiftMask, CHAIN, KEY, tag, …
116 + { MODKEY|ControlMask|ShiftMask, CHAIN, KEY, toggletag, …
117
118 /* helper for spawning shell commands in the pre dwm-5.0 fashion */
119 #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL }…
120 @@ -60,40 +60,42 @@ static const char *dmenucmd[] = { "dmenu_run", "-m",…
121 static const char *termcmd[] = { "st", NULL };
122
123 static Key keys[] = {
124 - /* modifier key function argu…
125 - { MODKEY, XK_p, spawn, {.v …
126 - { MODKEY|ShiftMask, XK_Return, spawn, {.v …
127 - { MODKEY, XK_b, togglebar, {0} …
128 - { MODKEY, XK_j, focusstack, {.i …
129 - { MODKEY, XK_k, focusstack, {.i …
130 - { MODKEY, XK_i, incnmaster, {.i …
131 - { MODKEY, XK_d, incnmaster, {.i …
132 - { MODKEY, XK_h, setmfact, {.f …
133 - { MODKEY, XK_l, setmfact, {.f …
134 - { MODKEY, XK_Return, zoom, {0} …
135 - { MODKEY, XK_Tab, view, {0} …
136 - { MODKEY|ShiftMask, XK_c, killclient, {0} …
137 - { MODKEY, XK_t, setlayout, {.v …
138 - { MODKEY, XK_f, setlayout, {.v …
139 - { MODKEY, XK_m, setlayout, {.v …
140 - { MODKEY, XK_space, setlayout, {0} …
141 - { MODKEY|ShiftMask, XK_space, togglefloating, {0} …
142 - { MODKEY, XK_0, view, {.ui…
143 - { MODKEY|ShiftMask, XK_0, tag, {.ui…
144 - { MODKEY, XK_comma, focusmon, {.i …
145 - { MODKEY, XK_period, focusmon, {.i …
146 - { MODKEY|ShiftMask, XK_comma, tagmon, {.i …
147 - { MODKEY|ShiftMask, XK_period, tagmon, {.i …
148 - TAGKEYS( XK_1, 0)
149 - TAGKEYS( XK_2, 1)
150 - TAGKEYS( XK_3, 2)
151 - TAGKEYS( XK_4, 3)
152 - TAGKEYS( XK_5, 4)
153 - TAGKEYS( XK_6, 5)
154 - TAGKEYS( XK_7, 6)
155 - TAGKEYS( XK_8, 7)
156 - TAGKEYS( XK_9, 8)
157 - { MODKEY|ShiftMask, XK_q, quit, {0} …
158 + /* modifier chain key key function…
159 + { MODKEY, -1, XK_p, spawn, …
160 + { MODKEY|ShiftMask, -1, XK_Return, spawn, …
161 + { MODKEY, -1, XK_b, toggleba…
162 + { MODKEY, -1, XK_j, focussta…
163 + { MODKEY, -1, XK_k, focussta…
164 + { MODKEY, -1, XK_i, incnmast…
165 + { MODKEY, -1, XK_d, incnmast…
166 + { MODKEY, -1, XK_h, setmfact…
167 + { MODKEY, -1, XK_l, setmfact…
168 + { MODKEY, -1, XK_Return, zoom, …
169 + { MODKEY, -1, XK_Tab, view, …
170 + { MODKEY|ShiftMask, -1, XK_c, killclie…
171 + { MODKEY, -1, XK_t, setlayou…
172 + { MODKEY, -1, XK_f, setlayou…
173 + { MODKEY, -1, XK_m, setlayou…
174 + { MODKEY, -1, XK_space, setlayou…
175 + { MODKEY|ShiftMask, -1, XK_space, togglefl…
176 + { MODKEY, -1, XK_0, view, …
177 + { MODKEY|ShiftMask, -1, XK_0, tag, …
178 + { MODKEY, -1, XK_comma, focusmon…
179 + { MODKEY, -1, XK_period, focusmon…
180 + { MODKEY|ShiftMask, -1, XK_comma, tagmon, …
181 + { MODKEY|ShiftMask, -1, XK_period, tagmon, …
182 + TAGKEYS( -1, XK_1, …
183 + TAGKEYS( -1, XK_2, …
184 + TAGKEYS( -1, XK_3, …
185 + TAGKEYS( -1, XK_4, …
186 + TAGKEYS( -1, XK_5, …
187 + TAGKEYS( -1, XK_6, …
188 + TAGKEYS( -1, XK_7, …
189 + TAGKEYS( -1, XK_8, …
190 + TAGKEYS( -1, XK_9, …
191 + { MODKEY|ShiftMask, -1, XK_q, quit, …
192 + { MODKEY, XK_a, XK_d, spawn, …
193 + { MODKEY, XK_a, XK_t, spawn, …
194 };
195
196 /* button definitions */
197 --
198 2.28.0
199
200
201 From e9f3eec82010fd6083dc57f058902a1aab2d14ea Mon Sep 17 00:00:00 2001
202 From: braunbearded <[email protected]>
203 Date: Wed, 29 Jul 2020 19:07:07 +0200
204 Subject: [PATCH 3/4] fix bug for mod key ignore
205
206 ---
207 dwm.c | 1 +
208 1 file changed, 1 insertion(+)
209
210 diff --git a/dwm.c b/dwm.c
211 index 7298c5e..aee56d4 100644
212 --- a/dwm.c
213 +++ b/dwm.c
214 @@ -1013,6 +1013,7 @@ keypress(XEvent *e)
215 XGrabKey(dpy, AnyKey, AnyModifier, root, True, …
216 GrabModeAsync);
217 } else if (!current && keysym == keys[i].keysym
218 + && keychain != -1
219 && keys[i].chain == keychain
220 && keys[i].func)
221 keys[i].func(&(keys[i].arg));
222 --
223 2.28.0
224
225
226 From 053e3a2b2ff87805a15f3fe2f82a7d8bf0ab9b7a Mon Sep 17 00:00:00 2001
227 From: braunbearded <[email protected]>
228 Date: Wed, 29 Jul 2020 21:25:23 +0200
229 Subject: [PATCH 4/4] listen for all keys inkl modifier after prefix
230
231 ---
232 dwm.c | 8 +++++---
233 1 file changed, 5 insertions(+), 3 deletions(-)
234
235 diff --git a/dwm.c b/dwm.c
236 index aee56d4..dea8f6a 100644
237 --- a/dwm.c
238 +++ b/dwm.c
239 @@ -993,10 +993,11 @@ isuniquegeom(XineramaScreenInfo *unique, size_t n,…
240 void
241 keypress(XEvent *e)
242 {
243 - unsigned int i;
244 + unsigned int i, j;
245 KeySym keysym;
246 XKeyEvent *ev;
247 int current = 0;
248 + unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockm…
249
250 ev = &e->xkey;
251 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
252 @@ -1010,8 +1011,9 @@ keypress(XEvent *e)
253 && keys[i].func) {
254 current = 1;
255 keychain = keysym;
256 - XGrabKey(dpy, AnyKey, AnyModifier, root, True, …
257 - GrabModeAsync);
258 + for (j = 0; j < LENGTH(modifiers); j++)
259 + XGrabKey(dpy, AnyKey, 0 | modifiers[j],…
260 + True, GrabModeAsync, Gr…
261 } else if (!current && keysym == keys[i].keysym
262 && keychain != -1
263 && keys[i].chain == keychain
264 --
265 2.28.0
266
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.