Commit graph

27 commits

Author SHA1 Message Date
Twilight0
f2f3cbceed X11: reduce typing delay for non-Latin characters (Greek, etc.)
Previously, typing non-Latin characters (e.g. Greek) via the X11 backend
was extremely slow (~1000ms per character) because the server had to
dynamically remap an unused keycode to the desired keysym via
XChangeKeyboardMapping. A blind 500ms sleep was used twice per character:
once before sending the key event (to wait for the mapping to propagate),
and once after (to wait for clients to process MappingNotify).

The root cause is that X11 key events only carry keycodes, not keysyms.
When a keysym has no existing keycode in the keyboard mapping, the app
must temporarily remap a keycode. Clients cache the keyboard mapping
locally and re-read it upon receiving a MappingNotify event from the
server. The race condition is that a client may process the key event
before it has processed the MappingNotify, interpreting the keycode with
the stale (old) mapping.

This patch replaces the blind pre-send sleep with a server-side
verification loop: after XChangeKeyboardMapping, it polls
XGetKeyboardMapping to confirm the server has applied the new mapping
before sending the key event. This is safe because XGetKeyboardMapping
reads directly from the server, which is the authority on the current
mapping. The post-send delay is reduced from 500ms to 50ms, which is
sufficient for clients to process MappingNotify on modern systems.

Expected improvement: non-Latin characters go from ~1000ms/char to
~55-60ms/char (verification ~5ms + post-send 50ms). Latin characters
remain instant as they already have existing keycode mappings.

The 500ms constant was overly conservative. The verification loop
provides a correct and responsive solution: it returns as soon as the
server confirms the mapping, and times out after 200ms as a safety net.

Fixes #46
2026-07-20 17:39:39 +03:00
Unrud
eebde58826 Update dependencies 2025-12-24 22:57:01 +01:00
Unrud
5771f44b0e Cleanup portal controller 2025-03-18 09:18:16 +01:00
Unrud
16dc47b570 Encrypt restore token 2025-03-18 09:18:15 +01:00
godalming
0fe41d0b15 Fix not being able to create restore token on snap because the cache directory does not exist 2025-03-17 20:21:35 +01:00
godalming
21461d9a76 Fix file permisions. Detect if restore tokens are not supported (version <= 1). Always log and continue if it is not possible to use a restore token rather than exit the program or log using fmt. 2025-03-17 00:19:48 +01:00
godalming
c6c54c77a7 Add support for session restore on the linux portals backend, fixing #77 2025-03-17 00:19:48 +01:00
Unrud
0ca1431594 Fix Xwayland detection with newer servers
Fixes #63
2024-01-23 19:33:15 +01:00
Unrud
e94fb986c0 Fix typo that causes error with xdg-desktop-portal-kde
Fixes #67
2024-01-23 14:11:16 +01:00
Unrud
c8e6664a8d Fix Windows controller
Partially revert 1794150285
Fixes #58
2023-05-21 00:53:33 +02:00
Unrud
c6fe56479a uinput: Fix vertical scroll direction 2023-05-08 22:31:34 +02:00
Unrud
1794150285 Simplify error handling 2023-05-08 22:31:02 +02:00
Unrud
51108765e3 Add null controller 2023-04-25 01:38:49 +02:00
Unrud
37dff3cb6b uinput: Detect unsupported platform 2023-04-25 01:38:48 +02:00
Unrud
891fde7051 Refactor errors 2023-04-25 01:38:48 +02:00
Unrud
0bd7260a0c uinput-controller: Show hint for setting keymap 2023-02-27 23:43:10 +01:00
Unrud
e69bd15733 uinput-controller: Lower priority 2023-02-27 23:42:16 +01:00
Unrud
bbb6cc4dc1 uinput-controller: Initial support for keymaps
Keymap can be set with environment variable REMOTE_TOUCHPAD_UINPUT_KEYMAP
2023-02-26 16:45:37 +01:00
Unrud
d254ae5b0d uinput-controller: Map runes/keys directly and handle errors 2023-02-23 02:07:14 +01:00
Unrud
809d3a0064 uinput-controller: Format code 2023-02-23 01:09:29 +01:00
De_Coder
feaf02217c improve uinput controller 2023-02-23 01:09:11 +01:00
De_Coder
f5d19a0354 Add uinput-based controller 2023-02-23 01:09:11 +01:00
Unrud
124152f7ec Include missing rune, key or button in error 2023-02-23 01:09:04 +01:00
Unrud
6f03281fc7 Refactor: Use switch statement 2023-02-23 01:09:03 +01:00
Unrud
681d9c4f1d Improve XWayland detection 2022-12-29 22:19:38 +01:00
Unrud
518c6ef952 Fix race in RemoteDesktop portal controller 2022-09-24 02:09:05 +02:00
Unrud
8a2a29c9d6 Reorganize 2022-06-20 03:48:43 +02:00