Introduction
Introduction Statistics Contact Development Disclaimer Help
dwm-keycodes-20230319-a38a8b3.diff - sites - public wiki contents of suckless.o…
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dwm-keycodes-20230319-a38a8b3.diff (7476B)
---
1 From a38a8b3310bd6fb4bb1371a5cad486ac280f773d Mon Sep 17 00:00:00 2001
2 From: Quentin Rameau <[email protected]>
3 Date: Tue, 10 Apr 2018 13:26:33 +0200
4 Subject: [PATCH] Use keycode for keyboard input instead of keysyms
5
6 ---
7 config.def.h | 68 ++++++++++++++++++++++++++--------------------------
8 dwm.c | 30 +++++++----------------
9 2 files changed, 42 insertions(+), 56 deletions(-)
10
11 diff --git a/config.def.h b/config.def.h
12 index 9efa774..b8ed024 100644
13 --- a/config.def.h
14 +++ b/config.def.h
15 @@ -61,40 +61,40 @@ static const char *dmenucmd[] = { "dmenu_run", "-m",…
16 static const char *termcmd[] = { "st", NULL };
17
18 static const Key keys[] = {
19 - /* modifier key function argu…
20 - { MODKEY, XK_p, spawn, {.v …
21 - { MODKEY|ShiftMask, XK_Return, spawn, {.v …
22 - { MODKEY, XK_b, togglebar, {0} …
23 - { MODKEY, XK_j, focusstack, {.i …
24 - { MODKEY, XK_k, focusstack, {.i …
25 - { MODKEY, XK_i, incnmaster, {.i …
26 - { MODKEY, XK_d, incnmaster, {.i …
27 - { MODKEY, XK_h, setmfact, {.f …
28 - { MODKEY, XK_l, setmfact, {.f …
29 - { MODKEY, XK_Return, zoom, {0} …
30 - { MODKEY, XK_Tab, view, {0} …
31 - { MODKEY|ShiftMask, XK_c, killclient, {0} …
32 - { MODKEY, XK_t, setlayout, {.v …
33 - { MODKEY, XK_f, setlayout, {.v …
34 - { MODKEY, XK_m, setlayout, {.v …
35 - { MODKEY, XK_space, setlayout, {0} …
36 - { MODKEY|ShiftMask, XK_space, togglefloating, {0} …
37 - { MODKEY, XK_0, view, {.ui…
38 - { MODKEY|ShiftMask, XK_0, tag, {.ui…
39 - { MODKEY, XK_comma, focusmon, {.i …
40 - { MODKEY, XK_period, focusmon, {.i …
41 - { MODKEY|ShiftMask, XK_comma, tagmon, {.i …
42 - { MODKEY|ShiftMask, XK_period, tagmon, {.i …
43 - TAGKEYS( XK_1, 0)
44 - TAGKEYS( XK_2, 1)
45 - TAGKEYS( XK_3, 2)
46 - TAGKEYS( XK_4, 3)
47 - TAGKEYS( XK_5, 4)
48 - TAGKEYS( XK_6, 5)
49 - TAGKEYS( XK_7, 6)
50 - TAGKEYS( XK_8, 7)
51 - TAGKEYS( XK_9, 8)
52 - { MODKEY|ShiftMask, XK_q, quit, {0} …
53 + /* modifier key function argument */
54 + { MODKEY, 33, spawn, {.v = dmenucmd …
55 + { MODKEY|ShiftMask, 36, spawn, {.v = termcmd }…
56 + { MODKEY, 56, togglebar, {0} }, …
57 + { MODKEY, 44, focusstack, {.i = +1 } }, …
58 + { MODKEY, 45, focusstack, {.i = -1 } }, …
59 + { MODKEY, 31, incnmaster, {.i = +1 } }, …
60 + { MODKEY, 40, incnmaster, {.i = -1 } }, …
61 + { MODKEY, 43, setmfact, {.f = -0.05} },…
62 + { MODKEY, 46, setmfact, {.f = +0.05} },…
63 + { MODKEY, 36, zoom, {0} }, …
64 + { MODKEY, 23, view, {0} }, …
65 + { MODKEY|ShiftMask, 54, killclient, {0} }, …
66 + { MODKEY, 28, setlayout, {.v = &layouts[…
67 + { MODKEY, 41, setlayout, {.v = &layouts[…
68 + { MODKEY, 58, setlayout, {.v = &layouts[…
69 + { MODKEY, 65, setlayout, {0} }, …
70 + { MODKEY|ShiftMask, 65, togglefloating, {0} }, …
71 + { MODKEY, 19, view, {.ui = ~0 } }, …
72 + { MODKEY|ShiftMask, 19, tag, {.ui = ~0 } }, …
73 + { MODKEY, 59, focusmon, {.i = -1 } }, …
74 + { MODKEY, 60, focusmon, {.i = +1 } }, …
75 + { MODKEY|ShiftMask, 59, tagmon, {.i = -1 } }, …
76 + { MODKEY|ShiftMask, 60, tagmon, {.i = +1 } }, …
77 + TAGKEYS( 10, 0) …
78 + TAGKEYS( 11, 1) …
79 + TAGKEYS( 12, 2) …
80 + TAGKEYS( 13, 3) …
81 + TAGKEYS( 14, 4) …
82 + TAGKEYS( 15, 5) …
83 + TAGKEYS( 16, 6) …
84 + TAGKEYS( 17, 7) …
85 + TAGKEYS( 18, 8) …
86 + { MODKEY|ShiftMask, 24, quit, {0} }, …
87 };
88
89 /* button definitions */
90 diff --git a/dwm.c b/dwm.c
91 index c2bd871..f710729 100644
92 --- a/dwm.c
93 +++ b/dwm.c
94 @@ -31,7 +31,6 @@
95 #include <sys/types.h>
96 #include <sys/wait.h>
97 #include <X11/cursorfont.h>
98 -#include <X11/keysym.h>
99 #include <X11/Xatom.h>
100 #include <X11/Xlib.h>
101 #include <X11/Xproto.h>
102 @@ -101,7 +100,7 @@ struct Client {
103
104 typedef struct {
105 unsigned int mod;
106 - KeySym keysym;
107 + KeyCode keycode;
108 void (*func)(const Arg *);
109 const Arg arg;
110 } Key;
111 @@ -954,26 +953,15 @@ grabkeys(void)
112 {
113 updatenumlockmask();
114 {
115 - unsigned int i, j, k;
116 + unsigned int i, j;
117 unsigned int modifiers[] = { 0, LockMask, numlockmask, …
118 - int start, end, skip;
119 - KeySym *syms;
120
121 XUngrabKey(dpy, AnyKey, AnyModifier, root);
122 - XDisplayKeycodes(dpy, &start, &end);
123 - syms = XGetKeyboardMapping(dpy, start, end - start + 1,…
124 - if (!syms)
125 - return;
126 - for (k = start; k <= end; k++)
127 - for (i = 0; i < LENGTH(keys); i++)
128 - /* skip modifier codes, we do that ours…
129 - if (keys[i].keysym == syms[(k - start) …
130 - for (j = 0; j < LENGTH(modifier…
131 - XGrabKey(dpy, k,
132 - keys[i].mod | …
133 - root, True,
134 - GrabModeAsync,…
135 - XFree(syms);
136 + for (i = 0; i < LENGTH(keys); i++)
137 + for (j = 0; j < LENGTH(modifiers); j++)
138 + XGrabKey(dpy, keys[i].keycode,
139 + keys[i].mod | modifiers[j], ro…
140 + True, GrabModeAsync, GrabModeA…
141 }
142 }
143
144 @@ -1000,13 +988,11 @@ void
145 keypress(XEvent *e)
146 {
147 unsigned int i;
148 - KeySym keysym;
149 XKeyEvent *ev;
150
151 ev = &e->xkey;
152 - keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
153 for (i = 0; i < LENGTH(keys); i++)
154 - if (keysym == keys[i].keysym
155 + if (ev->keycode == keys[i].keycode
156 && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
157 && keys[i].func)
158 keys[i].func(&(keys[i].arg));
159 --
160 2.40.0
161
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.