[Spice-devel] [PATCH spice-gtk] vncdisplaykeymap: Add support for Xwayland keymap

Pavel Grunt pgrunt at redhat.com
Wed Feb 18 06:43:11 PST 2015


From: "Daniel P. Berrange" <berrange at redhat.com>

Both Wayland and Xwayland use the evdev + 8 map for keycodes,
just as regular Xorg with evdev does.

This code is copied from gtk-vnc.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=89105
---
 gtk/vncdisplaykeymap.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gtk/vncdisplaykeymap.c b/gtk/vncdisplaykeymap.c
index 340a86f..32fdac5 100644
--- a/gtk/vncdisplaykeymap.c
+++ b/gtk/vncdisplaykeymap.c
@@ -12,6 +12,7 @@
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
 #include <gdk/gdkkeysyms.h>
+#include <stdlib.h>
 #include "gtk-compat.h"
 #include "vncdisplaykeymap.h"
 
@@ -156,6 +157,17 @@ static gboolean check_for_xquartz(GdkDisplay *dpy)
 
 	return match;
 }
+
+static gboolean check_for_xwayland(GdkDisplay *dpy G_GNUC_UNUSED)
+{
+	/* There is no obvious extension name or root window property
+	 * that identifies as Xwayland. It also does not report any
+	 * XKB info. So this env var check is least-worst option left
+	 */
+	char *dpystr = getenv("WAYLAND_DISPLAY");
+
+	return dpystr != NULL;
+}
 #endif
 
 const guint16 *vnc_display_keymap_gdk2xtkbd_table(GdkWindow *window,
@@ -195,6 +207,10 @@ 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 (check_for_xwayland(dpy)) {
+			VNC_DEBUG("Using wayland evdec keycode mapping");
+			*maplen = G_N_ELEMENTS(keymap_xorgevdev2xtkbd);
+			return keymap_xorgevdev2xtkbd;
 		} else if (keycodes && STRPREFIX(keycodes, "evdev_")) {
 			VNC_DEBUG("Using evdev keycode mapping");
 			*maplen = G_N_ELEMENTS(keymap_xorgevdev2xtkbd);
-- 
2.3.0



More information about the Spice-devel mailing list