mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Bump to 89f9905.
grabkeys: Avoid missing events when a keysym maps to multiple keycodes It's not uncommon for one keysym to map to multiple keycodes. For example, the "play" button on my keyboard sends keycode 172, but my bluetooth headphones send keycode 208, both of which map back to XF86AudioPlay: % xmodmap -pke | grep XF86AudioPlay keycode 172 = XF86AudioPlay XF86AudioPause XF86AudioPlay XF86AudioPause keycode 208 = XF86AudioPlay NoSymbol XF86AudioPlay keycode 215 = XF86AudioPlay NoSymbol XF86AudioPlay This is a problem because the current code only grabs a single one of these keycodes, which means that events for any other keycode also mapping to the bound keysym will not be handled by dwm. In my case, this means that binding XF86AudioPlay does the right thing and correctly handles my keyboard's keys, but does nothing on my headphones. I'm not the only person affected by this, there are other reports[0]. In order to fix this, we look at the mappings between keycodes and keysyms at grabkeys() time and pick out all matching keycodes rather than just the first one. The keypress() side of this doesn't need any changes because the keycode gets converted back to a canonical keysym before any action is taken. 0: https://github.com/cdown/dwm/issues/11 Ref. https://git.suckless.org/dwm/commit/89f9905714c1c1b2e8b09986dfbeca15b68d8af8.html
This commit is contained in:
parent
dc4e535b25
commit
4c32f6f52d
@ -1,4 +1,4 @@
|
|||||||
This dwm 6.4 (ba56fe9, 2022-10-28) side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. Due to the complexity of some of the patches dwm-flexipatch has diverged from mainstream dwm by making some core patches non-optional for maintenance reasons. For the classic dwm-flexipatch build refer to branch [dwm-flexipatch-1.0](https://github.com/bakkeby/dwm-flexipatch/tree/dwm-flexipatch-1.0).
|
This dwm 6.4 (89f9905, 2022-12-07) side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. Due to the complexity of some of the patches dwm-flexipatch has diverged from mainstream dwm by making some core patches non-optional for maintenance reasons. For the classic dwm-flexipatch build refer to branch [dwm-flexipatch-1.0](https://github.com/bakkeby/dwm-flexipatch/tree/dwm-flexipatch-1.0).
|
||||||
|
|
||||||
For example to include the `alpha` patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/dwm-flexipatch/blob/master/patches.def.h):
|
For example to include the `alpha` patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/dwm-flexipatch/blob/master/patches.def.h):
|
||||||
```c
|
```c
|
||||||
|
38
dwm.c
38
dwm.c
@ -2281,24 +2281,38 @@ grabkeys(void)
|
|||||||
{
|
{
|
||||||
updatenumlockmask();
|
updatenumlockmask();
|
||||||
{
|
{
|
||||||
unsigned int i, j;
|
unsigned int i, j, k;
|
||||||
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
|
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
|
||||||
KeyCode code;
|
int start, end, skip;
|
||||||
|
KeySym *syms;
|
||||||
|
|
||||||
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||||
for (i = 0; i < LENGTH(keys); i++)
|
XDisplayKeycodes(dpy, &start, &end);
|
||||||
if ((code = XKeysymToKeycode(dpy, keys[i].keysym)))
|
syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip);
|
||||||
for (j = 0; j < LENGTH(modifiers); j++)
|
if (!syms)
|
||||||
XGrabKey(dpy, code, keys[i].mod | modifiers[j], root,
|
return;
|
||||||
True, GrabModeAsync, GrabModeAsync);
|
for (k = start; k <= end; k++)
|
||||||
|
for (i = 0; i < LENGTH(keys); i++)
|
||||||
|
/* skip modifier codes, we do that ourselves */
|
||||||
|
if (keys[i].keysym == syms[(k - start) * skip])
|
||||||
|
for (j = 0; j < LENGTH(modifiers); j++)
|
||||||
|
XGrabKey(dpy, k,
|
||||||
|
keys[i].mod | modifiers[j],
|
||||||
|
root, True,
|
||||||
|
GrabModeAsync, GrabModeAsync);
|
||||||
#if ON_EMPTY_KEYS_PATCH
|
#if ON_EMPTY_KEYS_PATCH
|
||||||
if (!selmon->sel)
|
if (!selmon->sel)
|
||||||
for (i = 0; i < LENGTH(on_empty_keys); i++)
|
for (k = start; k <= end; k++)
|
||||||
if ((code = XKeysymToKeycode(dpy, on_empty_keys[i].keysym)))
|
for (i = 0; i < LENGTH(on_empty_keys); i++)
|
||||||
for (j = 0; j < LENGTH(modifiers); j++)
|
/* skip modifier codes, we do that ourselves */
|
||||||
XGrabKey(dpy, code, on_empty_keys[i].mod | modifiers[j], root,
|
if (on_empty_keys[i].keysym == syms[(k - start) * skip])
|
||||||
True, GrabModeAsync, GrabModeAsync);
|
for (j = 0; j < LENGTH(modifiers); j++)
|
||||||
|
XGrabKey(dpy, k,
|
||||||
|
on_empty_keys[i].mod | modifiers[j],
|
||||||
|
root, True,
|
||||||
|
GrabModeAsync, GrabModeAsync);
|
||||||
#endif // ON_EMPTY_KEYS_PATCH
|
#endif // ON_EMPTY_KEYS_PATCH
|
||||||
|
XFree(syms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user