FreeRDP / FreeRDP

FreeRDP is a free remote desktop protocol library and clients
http://www.freerdp.com/
Apache License 2.0
10.82k stars 14.76k forks source link

Wrong keyboard layout in remote app mode #10591

Closed FrnchFrgg closed 1 week ago

FrnchFrgg commented 1 week ago

Describe the bug

When connecting to Windows 11 Pro "full session" with command line xfreerdp3 /v:host the keyboard layout is correctly obeyed and translated by xfreerdp (the windows is setup to use French AZERTY and the linux client also uses French AZERTY).

But when connecting to a single application as in xfreerdp3 /v:host /app:program:explorer.exe then the keyboard layout becomes QWERTY, ignoring both the local (client) keyboard layout but also the default layout set on the Windows machine.

Options like /kbd:layout:<id> do not fix the problem. /kbd:unicode fixes the letters but CTRL+<key> combos are no longer detected. (while reading bug reports I thought that using /kbd:unicode in desktop/session mode would also break CTRL+<key> combos but in my tests it did not)

To Reproduce

  1. Run podman run -it -p 3389:3389/tcp -p 3389:3389/udp -p 8006:8006 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 120 --env VERSION=win11 --env LANGUAGE=French -v ./toto:/toto docker.io/dockurr/windows to get a French-configured windows
  2. While waiting for it to be up and running, add and select the French default keyboard in your desktop environment of choice. [EDIT: Not needed, on a machine that is not in AZERTY I get the same inconsistency]
  3. Run xfreerdp /v:localhost /u:Docker /p: and notice that the server keyboard layout is correctly used
  4. Run xfreerdp /v:localhost /u:Docker /p: /app:program:explorer.exe and notice the keyboard is now QWERTY [EDIT: which is neither the client layout nor the server layout]

Expected behavior The keyboard behaviour should be the same in step 4 and 5.

Application details

akallabeth commented 1 week ago

are you sure the keyboard layout is set to french in that case server side? The local layout is ignored (we extract the scancodes from the keys pressed with some magic), only the server side layout is relevant. in both cases the same layout id is sent to the server, but with remote-app there is usually a small window where you can set the current active keyboard layout should you have multiple installed

FrnchFrgg commented 1 week ago

I am totally certain that the keyboard is set to french server side, and without remote-app I get french layout (even if my keyboard is not in french AZERTY client-side). To sum up:

EDIT: I do not see the language bar or similar in remote-app case, nor in desktop mode (in the latter case this is normal since the client and server layout is the same.

EDIT2: The windows server has only french AZERTY set up. This is not a case of a wrong default selection in the case of multiple installed layouts.

akallabeth commented 1 week ago

@FrnchFrgg I´ve just tested this. It is working if you start a new session on the server. If you reconnect to an existing session the last set value is used and the layout you send is ignored.

Try to log out all your server side sessions and connect again. closing as resolved, ping me if it still does not work.

FrnchFrgg commented 1 week ago

I'll try soon. Two questions that may hint at a bug nevertheless:

  1. Do I need to explicitly send a French layout with /kbd or not ? Why, if the server default is French ? I never sent any layout setting until I noticed a problem (and at the time both client and server used AZERTY).
  2. Why is the behavior different between the remote-app and the desktop case ?
akallabeth commented 1 week ago

@FrnchFrgg

  1. you need to send something, there is no way to send nothing.
  2. it is up to the server to do something with this, so ask microsoft ;)
FrnchFrgg commented 1 week ago

there is no way to send nothing.

What I meant is « why do I need to use the /kbd:layout:0x000040C option if this is the server default layout ? ». Maybe xfreerdp3 is sending something anyway if I do not use that option.

I just tested and if I always connect using the above option then indeed the layout is correct in both desktop and remote-app modes, but that was using a windows 10 image (same docker, but with win10 setting). I'll have access to a windows 11 later.

akallabeth commented 1 week ago

there is no way to send nothing.

What I meant is « why do I need to use the /kbd:layout:0x000040C option if this is the server default layout ? ». Maybe xfreerdp3 is sending something anyway if I do not use that option.

it always sends the detected keyboard layout. if that is different from what you expect (or want a different layout remotely) you need to add /kbd option