use exact XkbKeysymToKeycode from tigervnc.

This commit is contained in:
Miroslav Šedivý 2021-04-12 13:25:10 +00:00
parent cb17046aee
commit 45e85c8864
2 changed files with 5 additions and 5 deletions

View File

@ -109,11 +109,11 @@ KeyCode XKeyEntryGet(KeySym keysym) {
} }
// From https://github.com/TigerVNC/tigervnc/blob/0946e298075f8f7b6d63e552297a787c5f84d27c/unix/x0vncserver/XDesktop.cxx#L343-L379 // From https://github.com/TigerVNC/tigervnc/blob/0946e298075f8f7b6d63e552297a787c5f84d27c/unix/x0vncserver/XDesktop.cxx#L343-L379
KeyCode KbdXKeysymToKeycode(Display *dpy, KeySym keysym) { KeyCode XkbKeysymToKeycode(Display* dpy, KeySym keysym) {
XkbDescPtr xkb; XkbDescPtr xkb;
XkbStateRec state; XkbStateRec state;
unsigned int mods; unsigned int mods;
KeyCode keycode; unsigned keycode;
xkb = XkbGetMap(dpy, XkbAllComponentsMask, XkbUseCoreKbd); xkb = XkbGetMap(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
if (!xkb) if (!xkb)
@ -142,7 +142,7 @@ KeyCode KbdXKeysymToKeycode(Display *dpy, KeySym keysym) {
// Shift+Tab is usually ISO_Left_Tab, but RFB hides this fact. Do // Shift+Tab is usually ISO_Left_Tab, but RFB hides this fact. Do
// another attempt if we failed the initial lookup // another attempt if we failed the initial lookup
if ((keycode == 0) && (keysym == XK_Tab) && (mods & ShiftMask)) if ((keycode == 0) && (keysym == XK_Tab) && (mods & ShiftMask))
return KbdXKeysymToKeycode(dpy, XK_ISO_Left_Tab); return XkbKeysymToKeycode(dpy, XK_ISO_Left_Tab);
return keycode; return keycode;
} }
@ -158,7 +158,7 @@ void XKey(KeySym keysym, int down) {
keycode = XKeyEntryGet(keysym); keycode = XKeyEntryGet(keysym);
if (keycode == 0) if (keycode == 0)
keycode = KbdXKeysymToKeycode(display, keysym); keycode = XkbKeysymToKeycode(display, keysym);
// Map non-existing keysyms to new keycodes // Map non-existing keysyms to new keycodes
if (keycode == 0) { if (keycode == 0) {

View File

@ -28,7 +28,7 @@ typedef struct xkeyentry_t {
static void XKeyEntryAdd(KeySym keysym, KeyCode keycode); static void XKeyEntryAdd(KeySym keysym, KeyCode keycode);
static KeyCode XKeyEntryGet(KeySym keysym); static KeyCode XKeyEntryGet(KeySym keysym);
static KeyCode KbdXKeysymToKeycode(Display *dpy, KeySym keysym); static KeyCode XkbKeysymToKeycode(Display *dpy, KeySym keysym);
void XKey(KeySym keysym, int down); void XKey(KeySym keysym, int down);
void XGetScreenConfigurations(); void XGetScreenConfigurations();