It seems the basic problem is that, by running VirtualBox in a window
manager window, an additional level of key mapping is introduced.

To explain how TurboVNC normally works in this regard:

The actual key symbol transmitted to the TurboVNC Server depends on the
client's keyboard layout, so if your client has a German layout,
pressing the key corresponding to '/' on an English keyboard will send
'-', pressing the key corresponding to 'Z' on an English keyboard will
send 'Y', and pressing the key corresponding to '[' on an English
keyboard will send umlaut U ('ü').  Since the baseline, unextended RFB
protocol transmits key symbols instead of key codes, the server will
interpret those key events as (respectively) '-', 'Y', and 'ü',
regardless of the keyboard layout that is selected in the TurboVNC
Server session.

Focusing on just those three keys, what I observe is the following when
running VirtualBox in a window manager window:

- Client layout: English, TurboVNC Server layout: English, Windows guest
layout: English

  'Z' key on English keyboard => 'Z' in TurboVNC Server and Windows guest
  '/' keyon English keyboard => '/' in TurboVNC Server and Windows guest
  '[' key on English keyboard => '[' in TurboVNC Server and Windows guest

- Client layout: German, TurboVNC Server layout: English, Windows guest
layout: English
  'Z' keyon English keyboard => 'Y' in TurboVNC Server and Windows guest
  '/' keyon English keyboard => '-' in TurboVNC Server and Windows guest
  '[' key on English keyboard => 'ü' in TurboVNC Server, nothing in
Windows guest

- Client layout: English, TurboVNC Server layout: English, Windows guest
layout: German
  'Z' keyon English keyboard => 'Z' in TurboVNC Server, 'Y' in Windows guest
  '/' keyon English keyboard => '/' in TurboVNC Server, '-' in Windows guest
  '[' key on English keyboard => '[' in TurboVNC Server, 'ü' in Windows
guest

- Client layout: German, TurboVNC Server layout: English, Windows guest
layout: German
  'Z' keyon English keyboard => 'Y' in TurboVNC Server, 'Z' in Windows guest
  '/' keyon English keyboard => '-' in TurboVNC Server, 'ß' in Windows guest
  '[' key on English keyboard => 'ü' in TurboVNC Server, nothing in
Windows guest

- Client layout: English, TurboVNC Server layout: German, Windows guest
layout: English
  'Z' key on English keyboard => 'Z' in TurboVNC Server, 'Y' in Windows
guest
  '/' keyon English keyboard => '/' in TurboVNC Server, '&' in Windows guest
  '[' key on English keyboard => '[' in TurboVNC Server, '8' in Windows
guest

- Client layout: German, TurboVNC Server layout: German, Windows guest
layout: English
  'Z' keyon English keyboard => 'Y' in TurboVNC Server, 'Z' in Windows guest
  '/' keyon English keyboard => '-' in TurboVNC Server, '/' in Windows guest
  '[' key on English keyboard => 'ü' in TurboVNC Server, '[' in Windows
guest

- Client layout: English, TurboVNC Server layout: German, Windows guest
layout: German
  'Z' keyon English keyboard => 'Z' in TurboVNC Server, 'Y' in Windows guest
  '/' keyon English keyboard => '/' in TurboVNC Server, '&' in Windows guest
  '[' key on English keyboard => '[' in TurboVNC Server, '8' in Windows
guest

- Client layout: German, TurboVNC Server layout: German, Windows guest
layout: German
  'Z' keyon English keyboard => 'Y' in TurboVNC Server and Windows guest
  '/' keyon English keyboard => '-' in TurboVNC Server and Windows guest
  '[' key on English keyboard => 'ü' in TurboVNC Server and Windows guest

Conclusions:
- When running VirtualBox in a window manager window, the keyboard
layout in the guest O/S determines which key symbol is actually received
by applications running in the guest.  That means that a German keyboard
layout must be selected in the Windows guest in order for the guest O/S
to properly interpret certain German key symbols.
- The client keyboard layout must match the TurboVNC Server session's
keyboard layout in order to avoid keyboard mapping errors.

You can also run VirtualBox without a window manager, by creating a
script and passing it to vncserver using the -xstartup option.  For
instance, here is a script I use:

# cat ~/3dscript
vglrun -nodl VirtualBox --startvm "Windows 7" --fullscreen

# /opt/TurboVNC/bin/vncserver -xstartup ~/3dscript

When started in this manner, the default behavior is the same as if an
English keyboard layout had been selected in the (non-existent) window
manager, because the TurboVNC Server defaults to a US XKEYBOARD layout
(this can be changed in custom TurboVNC Server builds by altering the
XKB_DFLT_* CMake variables.)  At run time, you can change the layout to
German by adding 'setxkbmap -layout de' to the custom xstartup script
prior to launching VirtualBox.

Note that there is a proposed feature
(https://github.com/TurboVNC/turbovnc/issues/108) that will allow for
optionally sending key codes from client to server instead of key
symbols, which means that only the keyboard layout in the TurboVNC
Server session would matter.  There are benefits to that approach in
terms of overall keyboard compatibility, since TurboVNC would not have
to translate O/S-specific or Java-specific key events on the client into
X11 key symbols.  Sending key codes would most likely prevent this
situation with VirtualBox.  At the very least, it should make it so that
VirtualBox behaves the same within a TurboVNC Server session as it does
on the local display.  Unfortunately, however, that feature is in need
of funding, so it won't make it into TurboVNC 2.2.  Hopefully it will be
in 2.3.  In the meantime, use the workaround described above.

DRC

On 5/4/18 12:25 PM, torsten wrote:
> Hi DRC,
>
> Am Freitag, 4. Mai 2018 16:22:27 UTC+2 schrieb DRC:
>
>     I'm not sure I'm clear on exactly what is happening.  When you say
>     "wrong layout", what is the visible symptom of the problem?  Do
>     you mean
>     that the keys are not translated correctly between client and server?
>     Or is the layout within the guest operating system actually changing?
>
>
> No, all OSs involved here (the guest OS, the host OS and the Client
> OS) think, they use the german layout. There is no change in keyboard
> layout configuration. Fact is, I get the characters in this table
> (hope you can read this table format):
>
> | Key pressed on keyboard | character appearing in VM |
> | zZ                      | yY                        |
> | &                       | /                         |
> | (                       | )                         |
> | *                       | (                         |
> | \                       | #                         |
> | >                       | :                         |
> | +                       | `                         |
> | #                       | §                         |
> | -                       | ß                         |
> | "                       | Ä                         |
> | /                       | -                         |
> | )                       | =                         |
> | =                       | '                         |
> | ?                       | _                         |
> | '                       | ä                         |
> | _                       | ?                         |
> | :                       | Ö                         |
> | ;                       | ö                         |
> | {                       | Ü                         |
> | [                       | ü                         |
> | ]                       | +                         |
> | }                       | *                         |
> | \                       | #                         |
> | ~                       | °                         |
> | @                       | "                         |
> | yY                      | zZ                        |
>
> Keep in mind to search these keys on a german keyboard! For some of
> them Shift or AltGr has to be hit additionally. Some keys (like Ä
> e.g.) normally providing a character do nothing in the VM.
>  
>
>     Also, when you run VirtualBox within TurboVNC, are you running it
>     exclusively, or are you using a window manager as well?
>
>
> The VM runs in a window managed by the window manager of the host.
>  
>
>      (what are the
>     contents of your ~/.vnc/xstartup.turbovnc file?)
>
>
> I found this file, but I never did any changes to it. It is in its
> original state like created by TurboVNC. And it is older than the
> installation of VirtualBox and the VM. It is attached here.
>
> Kind Regards
> Torsten
>  
>
>
>     On 5/4/18 5:28 AM, torsten wrote:
>     > Hi,
>     >
>     > on the host I'm connected via TurboVNC I have a VirtualBox VM.
>     Inside
>     > this VM I obviously get the default english keyboard layout
>     instead of
>     > the german one I'm really using. When I sit at the console and
>     work with
>     > the VM without using the TurboVNC session, all keys are correct.
>     All
>     > other software on the host accessed via TurboVNC gets the
>     correct keys
>     > too  The wrong layout comes back, when I use the local TurboVNC
>     Client
>     > connecting the same session and start the VM within it. Is there
>     a way
>     > to get the correct keyboard layout in the VM accessed via TurboVNC?
>     >
>     > Kind Regards
>     > Torsten
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "TurboVNC User Discussion/Support" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/turbovnc-users/1d25c323-7eb6-4a41-8dc2-8c049ac0f183%40googlegroups.com
> <https://groups.google.com/d/msgid/turbovnc-users/1d25c323-7eb6-4a41-8dc2-8c049ac0f183%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"TurboVNC User Discussion/Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/turbovnc-users/baf5eeee-b471-fe2c-851c-830655756e07%40virtualgl.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to