TigerVNC / tigervnc

High performance, multi-platform VNC client and server
https://tigervnc.org
GNU General Public License v2.0
5.09k stars 934 forks source link

Input system does scans only the first layout for symbols #1745

Open twaik opened 5 months ago

twaik commented 5 months ago

Describe the bug Hello. It seems like when you try to input symbol from layout which is not selected as current layout X server does not even try to scan secondary (or non-selected) layout and to use it. Only primary layout and it's shift levels are being used.

To Reproduce

  1. Start server with vncserver -SecurityTypes None -xstartup xterm -fg.
  2. Start xev in xterm window.
  3. Use setxkbmap us,ru on both main and vncserver's X servers.
  4. Switch to russian layout with alt-shift (if alt-shift toggle is configured) or use your DE's layout switcher (only on main X server).
  5. Try to input russian symbols in xev's window.

Xev will show you scratch (fake?) keycodes and not real keycodes that you can reproduce on your local X server.

Expected behavior X server should scan secondary layouts to find symbols and switch layouts when needed.

Screenshots image

Client (please complete the following information):

Server (please complete the following information):

Additional context N/a

CendioOssman commented 5 months ago

XKB's group system is rather complex, but it could be worth exploring if this could be used. Switching group isn't as obvious as the other states, though, so I'm not sure exactly what needs to be done here.

CendioOssman commented 5 months ago

This could be a mitigation for #93.

twaik commented 5 months ago

I implemented scanning layouts and switching layout before inputting symbol (in XCB, not on X server side) a while ago, I hope it will be helpful. https://github.com/termux/termux-x11/blob/62bf17ddf8a8cacd945f8ef3fa9e91cec42fa39c/app/src/main/cpp/lorie/xcb-connection.hpp#L254-L515 The most interesting parts are reload_keymaps (which scans the whole keymap table including all layouts) and send_keysym which sends symbols with changing layout before sending key event and restoring it after that.