[Spice-devel] [PATCH spice-gtk] vncdisplaykeymap: Add support for Xwayland keymap
Marc-André Lureau
mlureau at redhat.com
Wed Feb 18 06:47:55 PST 2015
----- Original Message -----
> 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
We already have wayland input support since:
commit 577263aaf4cffe260e31d19eb4b8bca1c253eff3
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Mon May 13 01:11:07 2013 +0200
vncdisplaykeymap: add wayland support
The Wayland keycode are just Linux evdev, but the Gdk backend
add the +8 offset used by Xorg evdev.
Not sure about XWayland, but I would assume this was enough, and didn't rely on a not so reliable environment variable.
More information about the Spice-devel
mailing list