summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-09-21 12:30:54 +0200
committerPierre Ossman <ossman@cendio.se>2018-09-21 12:30:54 +0200
commit3b532f87b26d791b0b64b87aa39141d1a81098e8 (patch)
tree6f52d0bd7d73dbbcecfec02c3cb372ce03d3c5eb /unix
parent764c60904b2be6d0e486f80eb9d541b7c331c4fc (diff)
downloadtigervnc-3b532f87b26d791b0b64b87aa39141d1a81098e8.tar.gz
tigervnc-3b532f87b26d791b0b64b87aa39141d1a81098e8.zip
Replace Shift+Alt with Shift+Meta when possible
Most layouts on Unix generate Meta for Shift+Alt but non-Unix clients will send XK_Alt_*. This results in us picking some other key which can confuse some applications. Try to detect this scenario and map XK_Alt_* to XK_Meta_*.
Diffstat (limited to 'unix')
-rw-r--r--unix/xserver/hw/vnc/Input.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/unix/xserver/hw/vnc/Input.c b/unix/xserver/hw/vnc/Input.c
index 228b382d..534e435e 100644
--- a/unix/xserver/hw/vnc/Input.c
+++ b/unix/xserver/hw/vnc/Input.c
@@ -489,6 +489,30 @@ static void vncKeysymKeyboardEvent(KeySym keysym, int down)
keycode = vncKeysymToKeycode(keysym, state, &new_state);
+ /*
+ * Shift+Alt is often mapped to Meta, so try that rather than
+ * allocating a new entry, faking shift, or using the dummy
+ * key entries that many layouts have.
+ */
+ if ((state & ShiftMask) &&
+ ((keysym == XK_Alt_L) || (keysym == XK_Alt_R))) {
+ KeyCode alt, meta;
+
+ if (keysym == XK_Alt_L) {
+ alt = vncKeysymToKeycode(XK_Alt_L, state & ~ShiftMask, NULL);
+ meta = vncKeysymToKeycode(XK_Meta_L, state, NULL);
+ } else {
+ alt = vncKeysymToKeycode(XK_Alt_R, state & ~ShiftMask, NULL);
+ meta = vncKeysymToKeycode(XK_Meta_R, state, NULL);
+ }
+
+ if ((meta != 0) && (alt == meta)) {
+ LOG_DEBUG("Replacing Shift+Alt with Shift+Meta");
+ keycode = meta;
+ new_state = state;
+ }
+ }
+
/* Try some equivalent keysyms if we couldn't find a perfect match */
if (keycode == 0) {
for (i = 0;i < sizeof(altKeysym)/sizeof(altKeysym[0]);i++) {