neutrinolabs / xrdp

xrdp: an open source RDP server
http://www.xrdp.org/
Apache License 2.0
5.8k stars 1.73k forks source link

Trouble with keyboard layout #915

Open diego-santacruz opened 7 years ago

diego-santacruz commented 7 years ago

I have installed xrdp with xorgxrdp on CentOS 7.4, connecting from a Windows 10 laptop with a fr-CH keyboard using the native Remote Desktop client.

When I first connect the keyboard layout inside xrdp is US. I can go to the Gnome regional settings and add the fr-CH, after which it works fine, until I disconnect.

When I disconnect and reconnect the keyboard layout is back to US, although the Gnome keyboard selector shows fr-CH. If I switch to US and back to fr-CH from the drop-down in the gnome top bar it does not change anything.

If I go back to the Gnome regional settings and modify the order of the keyboards, then the effective keyboard layout is back to fr-CH.

I would expect xrdp to use the client's keyboard layout (ideally) or at least remember the layout selected on the last connection.

Using "setxkbmap -query" it appears that when the client reconnects the keyboard maps are reset. After initially adding the fr-CH keyboard

#  setxkbmap -query
rules:      base
model:      pc104
layout:     us,ch,us
variant:    ,fr,

After disconnecting and reconnecting, there is only the US keyboard map.

#  setxkbmap -query
rules:      base
model:      pc104
layout:     us

The versions installed are: xrdp-0.9.3-2.el7.x86_64 xorgxrdp-0.2.4-3.el7.x86_64 Windows 10 Remote Desktop client 10.0.15063

metalefty commented 7 years ago

I suspect DE's keyboard selector overriding the keyboard layout. Can you confirm with the simplest WM (ex. xterm)?

Make startwm.sh simplest, and connect & reconnect, see setxkbmap result.

#!/bin/sh
xterm
diego-santacruz commented 7 years ago

I've done the test, and it is the same thing with just xterm, so it does not appear that the DE is the culprit.

  1. When I initially connect I have only the us layout
    $ setxkbmap -v 10 -print
    Setting verbose level to 10
    locale is C
    Trying to load rules file ./rules/base...
    Trying to load rules file /usr/share/X11/xkb/rules/base...
    Success.
    Applied rules from base:
    rules:      base
    model:      pc104
    layout:     us
    Trying to build keymap using the following components:
    keycodes:   xfree86+aliases(qwerty)
    types:      complete
    compat:     complete
    symbols:    pc+us
    geometry:   pc(pc104)
    xkb_keymap {
        xkb_keycodes  { include "xfree86+aliases(qwerty)"       };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+us" };
        xkb_geometry  { include "pc(pc104)"     };
    };
  2. I then add the fr-CH layout
    $ setxkbmap -v 10 -layout ch,us -variant fr, -option grp:caps_toggle
    Setting verbose level to 10
    locale is C
    Warning! Multiple definitions of keyboard layout
         Using command line, ignoring X server
    Trying to load rules file ./rules/base...
    Trying to load rules file /usr/share/X11/xkb/rules/base...
    Success.
    Applied rules from base:
    rules:      base
    model:      pc104
    layout:     ch,us
    variant:    fr,
    options:    grp:caps_toggle
    Trying to build keymap using the following components:
    keycodes:   xfree86+aliases(qwerty)
    types:      complete
    compat:     complete
    symbols:    pc+ch(fr)+us:2+capslock(grouplock)
    geometry:   pc(pc104)
  3. Now I have the fr-CH layout active and I can switch between the two with Caps Lock.
  4. I disconnect the client and reconnect back again
  5. The keyboard layout is back to US, actually the complete keyboard layout definition was reset back to the original, so some kind of reset is occurring on reconnection.
    $ setxkbmap -v 10 -print
    Setting verbose level to 10
    locale is C
    Trying to load rules file ./rules/base...
    Trying to load rules file /usr/share/X11/xkb/rules/base...
    Success.
    Applied rules from base:
    rules:      base
    model:      pc104
    layout:     us
    Trying to build keymap using the following components:
    keycodes:   xfree86+aliases(qwerty)
    types:      complete
    compat:     complete
    symbols:    pc+us
    geometry:   pc(pc104)
    xkb_keymap {
        xkb_keycodes  { include "xfree86+aliases(qwerty)"       };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+us" };
        xkb_geometry  { include "pc(pc104)"     };
    };
diego-santacruz commented 7 years ago

A tad more info, when I reconnect there is the following message in the xorgxrdp server log

[ 82044.634] rdpClientConGotConnection:
[ 82044.634] rdpClientConGotConnection: g_sck_accept ok new_sck 16
[ 82044.634] rdpClientConGotConnection: adding only clientCon
[ 82044.635] rdpClientConProcessMsgVersion: version 0 0 0 1
[ 82044.635] rdpClientConProcessScreenSizeMsg: set width 1280 height 1024 bpp 16
[ 82044.635] rdpClientConProcessScreenSizeMsg: shmemid 18874371 shmemptr 0x7f961e808000
[ 82044.635] rdpClientConProcessMsgClientInput: invalidate x 0 y 0 cx 1280 cy 1024
[ 82044.638] rdpClientConProcessMsgClientInfo:
[ 82044.638]   got client info bytes 5744
[ 82044.638]   jpeg support 0
[ 82044.638]   offscreen support 1
[ 82044.638]   offscreen size 5242880
[ 82044.638]   offscreen entries 100
[ 82044.639]   client can not do offscreen to offscreen blits
[ 82044.639]   client can do new(color) cursor
[ 82044.639]   client can not do multimon
[ 82044.639] rdpRRSetRdpOutputs: numCrtcs 1 monitorCount 0
[ 82044.639] rdpRRSetRdpOutputs: update output 0 left 0 top 0 width 1280 height 1024
[ 82044.639] rdpLoadLayout: keylayout 0x0000100c variant  display 10 ### <---- THIS ONE

So apparently the keyboard layout is being reloaded.

metalefty commented 7 years ago

Do you want to use both US and fr-CH and switch them on-the-fly?

diego-santacruz commented 7 years ago

Do you want to use both US and fr-CH and switch them on-the-fly?

Not necessarily, but it is what it will end up as since upon connection the client's layout is not passed (at least with the Windows RD client), so the practical thing would be to have both layouts installed and switch back when reconnecting. The ideal would be to have the client's layout reused.

But note that the layout is also reset to US even if install just the fr-CH layout with

$ setxkbmap -v 10 -layout ch -variant fr
ViperRu commented 7 years ago

May be this will help:

add strings into xrdp_keyboard.ini


[rdp_keyboard_fr]
keyboard_type=4
keyboard_subtype=1
model=pc104
variant=fr
options=grp:caps_toggle
rdp_layouts=default_rdp_layouts
layouts_map=layouts_map_ch

[layouts_map_ch] rdp_layout_us=ch,us rdp_layout_ch=ch,us

cypa commented 6 years ago

I confirm same problem with Russian/US kbd swithing on CentOS 7.4 (client is Alpine Linex 3.7 xfreerdp) any solutions or suggestions?

omawnakw commented 6 years ago

I confirm the same thing with Windows 8 mstsc client. Xrdp just resets the xkb setting on new connection. And it's not the [default] section of xrdp_keyboard.ini applied - it's ignored also - I've tried to put option and correct layout into it. I even tried to delete the default section or duplicate the rdp_keyboard_ru with this name. Or even drop all keyboard sections except default - nothing helps. But on the same configuration everyting OK with Microsoft Remote Desktop for Mac Version 8.0.43 (Build 27325).

LosD commented 5 years ago

I have the same problem with Ubuntu 18.04 LTS running in Hyper-V. On startup, everything is good, but if I disconnect and reconnect, my (da-dk) keyboard is US.

By the way, even on first startup the login screen is using US keyboard.

endofreal commented 3 years ago

Up!

ghost commented 3 years ago

same for me: on reconnection I have suddenly a US keyboart layout

ndeffayet commented 1 year ago

Is it possible to take the client keyboard layout and apply on server side without require some tunning on server side ?

apivovarov commented 1 year ago

Same issue with AlmaLinux 9 - input language switch is ignored in XRDP session and works fine in VirtualBox graphical session - https://almalinux.discourse.group/t/xrdp-keyboard-input-language-switch-is-ignored-always-prints-in-english/2391

apivovarov commented 1 year ago

Related issue - Keyboard always types in English regardless of selected Input Language - https://github.com/neutrinolabs/xrdp/issues/2656

matt335672 commented 2 days ago

I'd appreciate comments on #3322 from anyone monitoring this, if they think it's relevant.