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 <ofour...@redhat.com>
---
 v2: Keep old code as requested, use scancodes to complement the check
     instead of replacing the previous logic entirely, as per the review
     on https://patchwork.freedesktop.org/patch/209141/.

 src/vncdisplaykeymap.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/vncdisplaykeymap.c b/src/vncdisplaykeymap.c
index 9ee501d..c86364b 100644
--- a/src/vncdisplaykeymap.c
+++ b/src/vncdisplaykeymap.c
@@ -195,11 +195,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;
-- 
2.14.3

_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to