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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

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

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





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]