Hacker News new | ask | show | jobs
by codedokode 679 days ago
Also, I am curious: why in X11 and Wayland keyboard code translation happens on the client side? Wouldn't it make more sense if the layout was stored only on the server and server did the translation? There would be no need to broadcast layout changes, for example.
2 comments

I had thought to design the window system and operating system, that the keyboard manager will handle the keyboard translation and can be set to several modes by application programs. Only the server knows the keyboard layout, although clients can tell the keyboard translation modes:

- Text input with large character sets (Extended TRON Code)

- Text input with small character sets (the application program can select which one (although it is not guaranteed to be available, unless the user installs an appropriate keyboard layout); e.g. APL character set)

- Command mode

- Game mode

- Hybrid mode

This way it can handle IME as well, and also specialized layouts for purposes (such as APL programming), and can handle nearly raw keyboard events when desired (although, for purposes of security and others, some combinations might still be handled by the operating system or by the window manager).

I don't think you need translation modes; you could simply send both raw events and translated events simultaneously and let client choose what it needs.
I do not agree. Translation modes will be necessary in order to handle IME properly, as well as for handling specialized character sets. (It may also mitigate some types of spying, possibly.)
The only thing I can think of is that some clients might want raw keyboard events. It does seem to me (an outsider) like Keysyms are the better level of abstraction for input for the overwhelming majority cases, and the translation should happen as early as possible in the server, and that's even before ignoring things like the asynchronous nature of xlib making keyboard remapping &c. unreliable for sending key events outside of the primary keymap.
But you can send both raw key codes and translated character code and let client decide what it needs (for example, for hotkeys like Ctrl + C you will probably prefer a raw key code so that it works independent of selected input language).