GNOME Bugzilla – Bug 731825
ALTGR key combinations broken in windows
Last modified: 2015-02-06 15:27:41 UTC
Using gtk-vnc 0.5.3 in Windows (e.g. virt-viewer) key combinations with ALT-GR are broken. E.g german keyboard and pressing ALTGR-E (Euro char), ALTGR-Q (@ char). Sample how to reproduce the bug 1. Compile virt-viewer for Win32 from scratch 2. Install virt-viewer 3. Connect to VM via VNC 4. Press ALTGR combinations 5. VNC console does not receive the correct chars. There are lengthy discussions throught the internet. Basically it boils down that the Windows keyboard combination ALTGR-<CHAR> triggers the key events LEFTCONTROL-DOWN -> RIGHTALT-DOWN -> <CHAR>-DOWN The additonal LEFTCONTROL hinders the VNC server to correctly translate the input. In spice there exists a workaround that deletes the LEFTCONTROL event in some cases. More here: http://lists.freedesktop.org/archives/spice-devel/2013-May/013429.html For VNC (at least for the mingw Windows build) there should exist a similar bugfix. The function in question is src/vncdisplay.c. Please excuse my hacky implementation. I do not know if it requires better recognition for other keyboard layouts than german. if (key->type == GDK_KEY_PRESS) { ... priv->down_keyval[i] = keyval; priv->down_scancode[i] = key->hardware_keycode; /* Send the actual key event we're dealing with */ + +#IFDEF WIN32_OR_WHATEVERFLAG + /* send "leftcontrol released" in case of "ALTGR pressed" */ + if (scancode == 184) + vnc_connection_key_event(priv->conn, 0, 65507, 29); + +#ENDIF vnc_connection_key_event(priv->conn, 1, keyval, scancode); break; } } } While spice has advanced windows functions to determine the really pressed key gtk-vnc relies on standard key events. So we cannot evaluate special windows scancodes. The only fall back is to insert an additional key-up event for ALT-GR. Above patch will send: LEFTCONTROL-DOWN -> LEFTCONTROL-UP -> RIGHTALT-DOWN -> <CHAR> Tested with german keyboard on virt-viewer 0.6.0 against qemu 1.6.2 VNC server.
Rather than do this patch you've suggested, I'm going to just copy the spice-gtk solution. Keeping the code in sync will make it easier to copy further bug fixes in this area.
Hopefully this is fixed in git in commit 590c344ad3340dfabb9985c98f418ce2fcae7b44 Author: Daniel P. Berrange <berrange@redhat.com> Date: Fri Feb 6 13:39:48 2015 +0000 Install hook for Windows key code handling