3 ms·
Not being able to make a keylogger is actually bad thing. Both X11 and Wayland have poorly designed keyboard events handling (which was defined in XKeyboard sp
by codedokode 8y ago
Not being able to make a keylogger is actually bad thing.
Both X11 and Wayland have poorly designed keyboard events handling (which was defined in XKeyboard spec in 1995). For example, you want to use Ctrl + Shift keys to switch keyboard layouts on release. Simple thing that is working in Windows. You cannot do that in Linux, because:
- if you assign Ctrl + Shift to switch keyboard layout then when these keys are pressed, the event will be consumed and you cannot use combinations like Ctrl + Shift + F (this will be interpreted as Ctrl + F or Shift + F depending on what key you have pressed earlier)
- you cannot make a separate program that would monitor all key presses and releases and switch layout without breaking other programs. In the X server and extensions there is no such feature as "monitoring pressed keys"
The only way to do it reliably is to have a privileged program that would listen to events in /dev/input.
By the way this bug hasn't been fixed for 14 years [1], and instead of fixing it the distributions have been using different hacks and workarounds. Also, they don't warn user that using Ctrl + Shift to switch layout will break hotkeys using these modifiers.
Another issue is remote control programs like VNC. In both X11 and Wayland to emulate user input VNC server muss pass a key number to the X server or Wayland compositor. Not a keysym, not a unicode codepoint, but rather a number of the key on a physical keyboard. Now guess what happens if VNC client's machine has a keyboard layout with characters not present in layout on VNC server's machine? Everything gets broken. Typical solution for this is to find unused key number and patch current keyboard layout before sending a key press event to the X server.
Because of the same reason on-screen keyboards on Linux cannot produce characters not present in keyboard layout. Emoji, for example.
[1] https://bugs.freedesktop.org/show_bug.cgi?id=865 https://bugs.freedesktop.org/show_bug.cgi?id=865
- yellow_lead 8y agoAre you referring specifically to Ctrl + Shift? Because I use Super + Space (think it's default) to switch between languages in Gnome on Fedora with Wayland and it works fine for me, even when an app has focus.
- codedokode 8y agoCtrl + Shift (or Alt + Shift) is what Windows uses so people migrating from Windows often choose this combination. It is actually a poor choice, because you have to remember which layout is selected and make mistakes, so you type something in the wrong layout, notice it and have to delete and retype it again. A better solution is to use non-modal layout switching, when you have a dedicated key for every layout. On Windows I use left and right Control keys (with a help of a closed-source program), so I always start typing with pressing one of them. But on Linux I cannot use them (I tried to write a program that would listen to /dev/input but found out that you cannot switch layout in Wayland-based Gnome from an external program because there is no API for this). Super + Space which is used on Macs, is also a poor choice. It is surprising that Apple, which manufactures it own hardware, was unable to just make dedicated keys for different layouts.
- emersion 8y ago>For example, you want to use Ctrl + Shift keys to switch keyboard layouts on release. This is possible in Wayland, it's up to the compositor. >Now guess what happens if VNC client's machine has a keyboard layout with characters not present in layout on VNC server's machine? This seems pretty normal to me. Remote keyboards are just like physical keyboards. Just configure VNC's keyboard to use the correct layout. (BTW I'm not sure I understand what you mean by "Everything is broken") >Because of the same reason on-screen keyboards on Linux cannot produce characters not present in keyboard layout. Emoji, for example. I don't know about X11's status on this, however in Wayland on-screen keyboards _can_ send unicode to the compositor via the standard text-input protocol [1]. [1]: https://github.com/wayland-project/wayland-protocols/blob/master/unstable/text-input/text-input-unstable-v3.xml https://github.com/wayland-project/wayland-protocols/blob/ma...
- j16sdiz 8y ago> ... up to the compositor. Is there anything like W3C or WHATWG for Wayland? We had implementation specific extension in HTML, and we all hate that until the browser implentor sat together.
- codedokode 8y ago> This is possible in Wayland, it's up to the compositor. Typically compositor uses libxkbcommon which suffers from the same problems that X server had. > Remote keyboards are just like physical keyboards. Just configure VNC's keyboard to use the correct layout. It is inconvenient and I don't think it would work. There is no such thing as "VNC keyboard". VNC client sends keysyms over the wire, so the VNC server has to convert them back to a key number, switch to necessary layout if there are several of them, turn off modifiers like Shift if necessary. This is too complicated. For example, x11vnc server doesn't support non-latin input correctly. > (BTW I'm not sure I understand what you mean by "Everything is broken") That many VNC servers cannot handle non-latin input correctly. > however in Wayland on-screen keyboards _can_ send unicode to the compositor via the standard text-input protocol This looks like an extension for implementing IME. You can see that there is no key press or key release events. These events are defined in wayland protocol spec [1] and they still use a key number. So you cannot send key press/release events for characters not present in current keyboard layout. [1] https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_keyboard https://wayland.freedesktop.org/docs/html/apa.html#protocol-...