Blob Blame History Raw
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Olivier Fourdan <ofourdan@redhat.com>
Date: Fri, 9 Mar 2018 09:30:00 +0100
Subject: [spice-gtk] Use scancode instead of keycode names
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When running on Xwayland, the keycode mapping property is not available,
which causes unknown keycode mapping errors and the keyboard doesn't
work.

Check for a known scancode (“XK_Page_Up”) which differs to distinguish
between “xfree86” and “evdev” when the there is no keycode name.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
---
 src/vncdisplaykeymap.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/vncdisplaykeymap.c b/src/vncdisplaykeymap.c
index 2a792136..86cc6bde 100644
--- a/src/vncdisplaykeymap.c
+++ b/src/vncdisplaykeymap.c
@@ -174,11 +174,13 @@ const guint16 *vnc_display_keymap_gdk2xtkbd_table(GdkWindow *window,
 			VNC_DEBUG("Using xquartz keycode mapping");
 			*maplen = G_N_ELEMENTS(keymap_xorgxquartz2xtkbd);
 			return keymap_xorgxquartz2xtkbd;
-		} else if (keycodes && STRPREFIX(keycodes, "evdev")) {
+		} else if ((keycodes && STRPREFIX(keycodes, "evdev")) ||
+			   (XKeysymToKeycode(xdisplay, XK_Page_Up) == 0x70)) {
 			VNC_DEBUG("Using evdev keycode mapping");
 			*maplen = G_N_ELEMENTS(keymap_xorgevdev2xtkbd);
 			return keymap_xorgevdev2xtkbd;
-		} else if (keycodes && STRPREFIX(keycodes, "xfree86")) {
+		} else if ((keycodes && STRPREFIX(keycodes, "xfree86")) ||
+			   (XKeysymToKeycode(xdisplay, XK_Page_Up) == 0x63)) {
 			VNC_DEBUG("Using xfree86 keycode mapping");
 			*maplen = G_N_ELEMENTS(keymap_xorgkbd2xtkbd);
 			return keymap_xorgkbd2xtkbd;