feat(kwin): end a chord chain at its timeout

An sxhkd chain (alt + w ; h) is realized by the engine: after the prefix only
the keys that can come next and Escape are grabbed, because KWin 6.8's own key
sequences never fire. What ends a chain that nobody finishes is the chord
timeout, and the engine has no clock: it is told the time with on_tick. Rather
than ticking on a timer forever, the engine now says when its pending chain
times out (Engine::deadline, in komorebi-hotkeys) and the transport sleeps until
then, calls on_tick, and grabs the keys of the mode again. With no chain pending
it does not wake up at all.

The daemon takes --chord-timeout in milliseconds, 3000 by default, the engine's
default and the module's chordTimeout to come.

A unit test follows the calls of a chain from its prefix to its deadline. The VM
test vm-keys-engine grows a section with an sxhkdrc passed as --keybindings and
a timeout of 1.5 s: Alt+W, H runs the binding and H does not reach wev; Alt+W,
Escape lets the next H reach wev; Alt+W and two seconds later L reaches wev and
runs nothing.
This commit is contained in:
LGUG2Z committed 2026-10-28 07:21:14 -07:00
1 parent 3f72eb84d1
commit 260d8ff03e
6 files changed
+153 -4

No files matched your search

+4 -1
View File
@@ -83,7 +83,10 @@ komorebic start -- --keybindings-mode auto
The daemon realizes the modes of an skhdrc (and the chains of an sxhkdrc that stay open)
itself: while a mode is active, only its keys are taken, and every other key reaches the
window as usual. The log says which mode the daemon is in after each change.
window as usual. The log says which mode the daemon is in after each change. A chord chain
of an sxhkdrc (`alt + w ; h`) works the same way: after `alt + w`, only the keys that can
come next and Escape are taken, until one of them is pressed or 3 seconds pass
(`--chord-timeout 1500` waits 1.5 seconds instead).
A daemon that is killed leaves its keys swallowed until it is started again; `komorebic stop`
gives them back.