[Spice-devel] [PATCH spice-gtk] win32: translate virtual-key code to scancode via MapVirtualKey
Marc-André Lureau
marcandre.lureau at gmail.com
Tue Oct 30 04:20:09 PDT 2012
Local client keyboard layout shouldn't affect hardware scancode sent
to guest, so that guest keyboard layout configuration can map it
properly.
Unfortunately, the Win32 GdkEventKey.hardware_keycode isn't a hardware
scancode, but the Windows virtual-key code. We could modify Gdk to
return the scancode (available in MSG.lParam or via global hook), but
that would mean some Gdk breakage, or some unnecessary complexity.
Instead, we can rely on MapVirtualKey(), which translates the
vitual-key code into a scan code using current keyboard layout.
This solves the following bug:
https://bugzilla.redhat.com/show_bug.cgi?id=871125
---
gtk/spice-widget.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 3febb66..07770f7 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -999,8 +999,13 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
if (!d->inputs)
return true;
+#ifdef WIN32
+ scancode = MapVirtualKey(key->hardware_keycode, MAPVK_VK_TO_VSC);
+#else
scancode = vnc_display_keymap_gdk2xtkbd(d->keycode_map, d->keycode_maplen,
key->hardware_keycode);
+#endif
+
switch (key->type) {
case GDK_KEY_PRESS:
send_key(display, scancode, 1);
--
1.7.11.7
More information about the Spice-devel
mailing list