[Spice-devel] [PATCH spice-gtk] vncdisplaykeymap: Use XkbGetMap and XkbGetNames instead of XkbGetKeyboard

Pavel Grunt pgrunt at redhat.com
Fri Feb 20 07:19:50 PST 2015


XkbGetKeyboard does not work in XWayland (bfo#89240).

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=89105
---
According to the discussion http://lists.freedesktop.org/archives/spice-devel/2015-February/018964.html I submitted bfo#89240,
which was closed with the advise to use XkbGetMap. This solution doesn't rely on an environment variable and works in XWayland.
---
 gtk/vncdisplaykeymap.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gtk/vncdisplaykeymap.c b/gtk/vncdisplaykeymap.c
index 340a86f..6bf351f 100644
--- a/gtk/vncdisplaykeymap.c
+++ b/gtk/vncdisplaykeymap.c
@@ -175,11 +175,12 @@ const guint16 *vnc_display_keymap_gdk2xtkbd_table(GdkWindow *window,
 		 * X servers..... patches welcomed.
 		 */
 
-		desc = XkbGetKeyboard(gdk_x11_display_get_xdisplay(dpy),
+		Display *xdisplay = gdk_x11_display_get_xdisplay(dpy);
+		desc = XkbGetMap(xdisplay,
 				      XkbGBN_AllComponentsMask,
 				      XkbUseCoreKbd);
 		if (desc) {
-			if (desc->names) {
+			if (XkbGetNames(xdisplay, XkbKeycodesNameMask, desc) == Success) {
 				keycodes = gdk_x11_get_xatom_name(desc->names->keycodes);
 				if (!keycodes)
 					g_warning("could not lookup keycode name");
@@ -195,11 +196,11 @@ 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")) {
 			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")) {
 			VNC_DEBUG("Using xfree86 keycode mapping");
 			*maplen = G_N_ELEMENTS(keymap_xorgkbd2xtkbd);
 			return keymap_xorgkbd2xtkbd;
-- 
2.3.0



More information about the Spice-devel mailing list