Backport patch to fix XF86XK_AudioPlay

This commit is contained in:
lhark 2023-01-25 17:55:36 +01:00
parent d0acbada9f
commit 834f2e6a5e

23
dwm.c
View file

@ -1270,16 +1270,23 @@ 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); XDisplayKeycodes(dpy, &start, &end);
for (i = 0; i < LENGTH(keys); i++) syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip);
if ((code = XKeysymToKeycode(dpy, keys[i].keysym))) for (k = start; k <= end; k++)
for (j = 0; j < LENGTH(modifiers); j++) for (i = 0; i < LENGTH(keys); i++)
XGrabKey(dpy, code, keys[i].mod | modifiers[j], root, /* skip modifier codes, we do that ourselves */
True, GrabModeAsync, GrabModeAsync); 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);
XFree(syms);
} }
} }