After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 731825 - ALTGR key combinations broken in windows
ALTGR key combinations broken in windows
Status: RESOLVED FIXED
Product: gtk-vnc
Classification: Other
Component: general
0.5.x
Other Windows
: Normal normal
: ---
Assigned To: gtk-vnc-maint
gtk-vnc-maint
Depends on:
Blocks:
 
 
Reported: 2014-06-18 07:37 UTC by Markus Stockhausen
Modified: 2015-02-06 15:27 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Markus Stockhausen 2014-06-18 07:37:54 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.
Comment 1 Daniel P. Berrange 2015-02-06 13:41:09 UTC
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.
Comment 2 Daniel P. Berrange 2015-02-06 15:27:41 UTC
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