Replace XKeysymToKeycode
See github issue #60 XKeysymToKeycode fails on keyboard-layouts that have the same keysym on different keycodes.
This commit is contained in:
parent
1a4deea501
commit
3e3235f522
17
dunst.c
17
dunst.c
@ -11,6 +11,7 @@
|
|||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/XKBlib.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
@ -1049,7 +1050,21 @@ void init_shortcut(keyboard_shortcut * ks)
|
|||||||
strtrim_end(str);
|
strtrim_end(str);
|
||||||
|
|
||||||
ks->sym = XStringToKeysym(str);
|
ks->sym = XStringToKeysym(str);
|
||||||
ks->code = XKeysymToKeycode(dc->dpy, ks->sym);
|
/* find matching keycode for ks->sym */
|
||||||
|
int min_keysym, max_keysym;
|
||||||
|
XDisplayKeycodes(dc->dpy, &min_keysym, &max_keysym);
|
||||||
|
|
||||||
|
ks->code = NoSymbol;
|
||||||
|
|
||||||
|
int level = ks->mask & ShiftMask ? 1 : 0;
|
||||||
|
|
||||||
|
for (int i = min_keysym; i <= max_keysym; i++) {
|
||||||
|
if (XkbKeycodeToKeysym(dc->dpy, i, 0, level) == ks->sym) {
|
||||||
|
ks->code = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ks->sym == NoSymbol || ks->code == NoSymbol) {
|
if (ks->sym == NoSymbol || ks->code == NoSymbol) {
|
||||||
fprintf(stderr, "Warning: Unknown keyboard shortcut: %s\n",
|
fprintf(stderr, "Warning: Unknown keyboard shortcut: %s\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user