aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-11-30 15:44:54 +0100
committerPierre Ossman <ossman@cendio.se>2018-11-30 15:44:54 +0100
commit4f19e757c3732a5b172e6149ca4827fac60b9cab (patch)
treeba252e5498fa29d1f7a90ed3c37affb75439dde3
parent36177f99a93ccb21ac0abfa0d3e2dc3315074917 (diff)
parent0255e1b004fe6518c650e9d12b8862c2b2dad30b (diff)
downloadtigervnc-4f19e757c3732a5b172e6149ca4827fac60b9cab.tar.gz
tigervnc-4f19e757c3732a5b172e6149ca4827fac60b9cab.zip
Merge branch 'altgr' of https://github.com/CendioOssman/tigervnc
-rw-r--r--unix/xserver/hw/vnc/InputXKB.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/unix/xserver/hw/vnc/InputXKB.c b/unix/xserver/hw/vnc/InputXKB.c
index 50a21309..f84a6e4f 100644
--- a/unix/xserver/hw/vnc/InputXKB.c
+++ b/unix/xserver/hw/vnc/InputXKB.c
@@ -1,6 +1,6 @@
/* Copyright (C) 2009 TightVNC Team
* Copyright (C) 2009 Red Hat, Inc.
- * Copyright 2013-2015 Pierre Ossman for Cendio AB
+ * Copyright 2013-2018 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -52,6 +52,14 @@
extern DeviceIntPtr vncKeyboardDev;
+static const KeyCode fakeKeys[] = {
+#ifdef __linux__
+ 92, 203, 204, 205, 206, 207
+#else
+ 8, 124, 125, 156, 127, 128
+#endif
+ };
+
static void vncXkbProcessDeviceEvent(int screenNum,
InternalEvent *event,
DeviceIntPtr dev);
@@ -430,17 +438,20 @@ size_t vncReleaseLevelThree(KeyCode *keys, size_t maxKeys)
KeyCode vncKeysymToKeycode(KeySym keysym, unsigned state, unsigned *new_state)
{
XkbDescPtr xkb;
- unsigned int key;
+ unsigned int key; // KeyCode has insufficient range for the loop
+ KeyCode fallback;
KeySym ks;
unsigned level_three_mask;
if (new_state != NULL)
*new_state = state;
+ fallback = 0;
xkb = GetMaster(vncKeyboardDev, KEYBOARD_OR_FLOAT)->key->xkbInfo->desc;
for (key = xkb->min_key_code; key <= xkb->max_key_code; key++) {
unsigned int state_out;
KeySym dummy;
+ size_t fakeIdx;
XkbTranslateKeyCode(xkb, key, state, &state_out, &ks);
if (ks == NoSymbol)
@@ -456,10 +467,35 @@ KeyCode vncKeysymToKeycode(KeySym keysym, unsigned state, unsigned *new_state)
if (state_out & LockMask)
XkbConvertCase(ks, &dummy, &ks);
- if (ks == keysym)
- return key;
+ if (ks != keysym)
+ continue;
+
+ /*
+ * Some keys are never sent by a real keyboard and are
+ * used in the default layouts as a fallback for
+ * modifiers. Make sure we use them last as some
+ * applications can be confused by these normally
+ * unused keys.
+ */
+ for (fakeIdx = 0;
+ fakeIdx < sizeof(fakeKeys)/sizeof(fakeKeys[0]);
+ fakeIdx++) {
+ if (key == fakeKeys[fakeIdx]) {
+ if (fallback == 0)
+ fallback = key;
+ break;
+ }
+ }
+ if (fakeIdx < sizeof(fakeKeys)/sizeof(fakeKeys[0]))
+ continue;
+
+ return key;
}
+ /* Use the fallback key, if one was found */
+ if (fallback != 0)
+ return fallback;
+
if (new_state == NULL)
return 0;