Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AltGr mapped incorrectly on Spanish keyboard #3292

Open
gsabdiv opened this issue Oct 29, 2024 · 6 comments · Fixed by #3313
Open

AltGr mapped incorrectly on Spanish keyboard #3292

gsabdiv opened this issue Oct 29, 2024 · 6 comments · Fixed by #3313
Labels

Comments

@gsabdiv
Copy link

gsabdiv commented Oct 29, 2024

xrdp version

0.10.1

Detailed xrdp version, build options

xrdp 0.10.1
  A Remote Desktop Protocol Server.
  Copyright (C) 2004-2024 Jay Sorg, Neutrino Labs, and all contributors.
  See https://github.com/neutrinolabs/xrdp for more information.

  Configure options:
      --build=x86_64-redhat-linux-gnu
      --host=x86_64-redhat-linux-gnu
      --program-prefix=
      --disable-dependency-tracking
      --prefix=/usr
      --exec-prefix=/usr
      --bindir=/usr/bin
      --sbindir=/usr/sbin
      --sysconfdir=/etc
      --datadir=/usr/share
      --includedir=/usr/include
      --libdir=/usr/lib64
      --libexecdir=/usr/libexec
      --localstatedir=/var
      --sharedstatedir=/var/lib
      --mandir=/usr/share/man
      --infodir=/usr/share/info
      --enable-fuse
      --enable-pixman
      --enable-painter
      --enable-vsock
      --enable-ipv6
      --with-socketdir=/run/xrdp
      --with-imlib2
      build_alias=x86_64-redhat-linux-gnu
      host_alias=x86_64-redhat-linux-gnu
      CFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection 
      LDFLAGS=-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
      CXXFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
      PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig

  Compiled with OpenSSL 1.1.1k  FIPS 25 Mar 2021

Operating system & version

Red Hat Enterprise Linux 8.10 (Ootpa)

Installation method

dnf / apt / zypper / pkg / etc

Which backend do you use?

tigervnc-1.13.1-12.el8_10.x86_64

What desktop environment do you use?

xterm

Environment xrdp running on

physical

What's your client?

mstsc.exe on Windows 10

Area(s) with issue?

Keyboard / Mouse

Steps to reproduce

  • Use a Windows machine with Spanish keyboard layout (also works with a German keyboard set to Spanish)
  • connect to the xrdp
  • try to type "[" which require using AltGr and the key that is two keys rioght to the "L".

✔️ Expected Behavior

get a [
(when running xev see a ISO_Level3_Shift for AltGr)

❌ Actual Behavior

get nothing
(when running xev see a Alt_R+Shift_L for AltGr, which does give you the "[" in some applications, but not all)

When attaching a Spanish keyboard to the Linuxmachine and running setxkbmap es, xrdp-genkeymap generates this, which is completely different to the file included in the release tarball. For some reason, the development version doesn't contain the 40a mapping.
keymapspanish.txt

Anything else?

I saw #2217, but I don't think it's related, no VMs involved.

@gsabdiv gsabdiv added the bug label Oct 29, 2024
@matt335672
Copy link
Member

@gsabdiv - it's almost certainly the same issue as #2217. However, since I blundered my way through that one I've learned a lot more about how keyboard mappings work. I'm hopeful we can come up with a better solution for you.

I've got an old CentOS 8 VM I can use to look at this. I'm also lacking a Spanish keyboard, but I think I can work around that.

A couple of initial questions for you:-

  1. I can't identify your keyboard on https://www.kbdlayout.info/. The Spanish keyboard listed appears to have a '{' for the Alt-GR on key you mention rather than the '['. Can you have a look at that site and tell me which keyboard you have?
  2. What is the output of sudo grep keymap /var/log/xrdp.log?

Thanks.

@gsabdiv
Copy link
Author

gsabdiv commented Oct 29, 2024

Sorry, I confused the keys. I don't have a Spanish one at my desk. You're right, { is in the row of the L key. (I think I got confused because xev did show [ and { being pressed)
The xrdp.logs do have several lines of this:
[INFO ] Loading keymap file /etc/xrdp/km-0000040a.ini
[WARN ] local keymap file for 0x0000040a found and doesn't match built in keymap, using local keymap file
They appeared before I created the new mapping.

@matt335672
Copy link
Member

I've had a look at this.

I've found an unrelated problem related to the Spanish keyboard, which is that the Left Alt key isn't being mapped correctly. We can come back to that.

The main problem we have is with the interface to TigerVNC, namely passing the AltGr key. You should be able to verify that on the login screen, this key is working as expected. The problem appears to be only when talking to the VNC server.

Historically, Windows VNC clients have not interfaced well with VNC servers. Microsoft decided to map the AltGr key to Ctrl + Alt. This has resulted in TigerVNC implementing all sorts of workarounds to cope with different clients sending different combinations which are supposed to represent AltGr:-

https://duckduckgo.com/?t=lm&q=tigervnc+altgr&atb=v320-1&ia=web

We seem to be falling foul of one of those workarounds. As far as I can tell, we're sending the correct KeySym 0xffea to TigerVNC, but it is being interpreted as ALT_L. I've tried disentangling this on the server side by changing the keymap, and hence changing the heuristic, but that's made quite a mess of the keyboard.

I'll raise a query with tigervnc and see if they can give me some ideas.

You can also try using the xorgxrdp package and the Xorg backend. That does not suffer from this problem.

@matt335672
Copy link
Member

I've just figured out a better fix for this - I've been getting confused between the right-hand ALT key (on some keyboards) and the AltGr key (on other keyboards).

@gsabdiv - Can you try installing this file as km-0000040a.ini?

km-0000040a.ini.txt

It's got changes in for the two Alt keys.

@matt335672
Copy link
Member

@gsabdiv - did you try this? If it works for you I can merge it in.

@gsabdiv
Copy link
Author

gsabdiv commented Nov 14, 2024

My Spanish colleague says it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants