This patch expands the semantics of timeout() to cover the case in which it is
used as a tap target. This facilitates a number of novel use cases, like
discriminating between single/double tap or implementing per-key oneshot
timeouts.
Specifically timeout() is now defined in terms of arbitrary key events rather
than the behaviour of the key to which it is bound (if any). The new definition
executes the second action if no key events occur before the timeout expires.
The implication of this is that when timeout() is executed as the result of a
tap action, action2 will be executed after the timeout expires unless another
key is struck in the interval. Note that this is backward compatible with the
old definition, since a key up event (i.e a tap) will result in a resolution to
the first action if timeout() is directly bound to a key.
For Example:
tab = overload(control, timeout(a, 100, b))
will presently produce no effect when 'tab' is tapped. Under the expanded
definition, tapping tab will produce 'b' if 100 milliseconds elapse without an
interceding key event.
overload() and timeout() rely on being able to store and execute descriptors
without tying them to specific key states. To achieve idempotence, oneshot()
currently neutralizes the upstroke of the activating key if the layer in
question is already active. This can yield an activation asymmetry in the rare
event that the oneshot descriptor is not associated with a physical key and is
activated while the associated layer is already active.
To fix this, we activate the layer for each oneshot depression and keep track
of the oneshot activation depth.
Sometimes it is desirable to transition directly from one
toggled layer to another.
This commit extends swap() to work not just with keys bound to layer(),
but also toggle() and oneshot(). For swaps which occur one layer
deep (the anticipated use case), this is rougly equivalent of a
clear() followed by toggle(<target>).
Eager layer activation seems to be more desirable for non time-based
overloading. In addition to facilitating modifier clicking for non-managed
mice, it appears some applications (E.g i3) care about isolated modifier down
events.
Treat each chord as a virtual key that is released
after all constituents are released. Constituent keys
may be used in conjunction with the active chord
after they have been released.
Switch to hungarian notation to distinguish between timeout and macro variants of
existing actions. The old names are kept for backward compatibility but will
eventually be removed.
toggle2 -> togglem
swap2 -> swapm
overload2 -> overloadt
overload3 -> overloadt2
oneshotm and layerm have also been added for completeness.
For the moment these are functionally equivalent the end-to-end python tests
(make test) without spinning up and exercising the daemon. Eventually they
should extend or complement them.
Mostly plumbing.
Summary:
- Key processing logic remains untouched.
- Simplified IPC logic.
- Streamlined the event loop.
- Consolidated config and descriptor parsing logic into config.[ch].
- Eliminated internal KEYD_* environment variables in favour of compile time macros.
- Added color coding to the daemon output.
- Load all configuration files on initialization.
The last change increases initialization time (on the order of μs) and resident
memory size, but simplifies the config logic and has the benefit of linting all
files immediately while also allowing for the introduction of in-daemon
reloading. This ultimately results in a net saving for the user since
most service managers are horrendously slow :(.
It also means hotplugged devices will use the in-memory config set (which
probably makes more sense anyway) instead of dynamically scanning the config
directory. This is more efficient for small config directories (<100 files),
but less efficient for large ones (uncommon).
Tidy up the parsing logic and make everything valid c11
while we are at it :P.
The patch also eliminates the optional macro argument from swap(),
replacing it with a dedicated function (swap2()).
This breaks compatibility with a small number of configs,
but makes things more consistent.
This patch attempts to minimize the number of extraneous modifier events. We
used to do this in v1, but impetuously abandoned the attempt in the name of
reducing code complexity.
We achieve this by strategically updating modifier state and internally
reintroducing key sequences as distinct (from macros) entities, which are tied
to the generating key down/up pair.
This will be transparent to most users, but should make the output sequences
easier to reason about and may help in certain edge cases (#184) or in the
case of software with buggy input systems (#181).
This patch makes simple macros of the form `<mods>-<key>` less noisy by
avoiding the redundant release/depression of modifiers which are already
active. This used to be the default behaviour prior to 2.3.0-rc, but was
changed to accommodate #128 (among other things). In most cases the
additional noise is transparent to the application, but notably breaks
Gnome tab-switching via swap, since Gnome cares about intermediate
modifier state.
Currently composite layers will be activated in the order in which they
are defined which can cause shorter sequences to take precedence over
longer ones. This patch ensures the longest composite sequence always
takes precedence.
The stock XCompose file which ships with most distros isn't exhaustive
and uses a number of layout specific keysyms intended to be easy to
memorize (rather than globally accessible). To circumvent this problem
we ship our own set of simplified compose definitions.
This patch passively monitors mouse events and passes them
through to the active keyboard in order to facilitate
clearing oneshot modifiers on click.
A byproduct of this is an increase the number of spurious wakeups
(caused by mouse movement since we can't exclusively monitor click
events) , but this seems to have an minimal performance impact
in practice.
This is a major release which breaks backward compatibility for
non-trivial configs. (we are still in beta after all :P).
In the absence of too much blowback this will probably become the final
v2 design.
Much of this harkens back to the v1, with some additional simplifications
and enhancements.
See DESIGN.md for a more detailed account.
Some applications make use of the alt (e.g firefox) and meta (e.g gnome)
keys in isolation. Thus it is necessary to interpose additional events
to prevent the likes of '<alt down> <alt up>' from being interpreted as
key presses.
E.G
[alt]
a = x
will currently cause 'alt+a' to produce:
<alt down>
<alt up>
<x down>
<x up>
In most cases this is identical to '<x>', however in some contexts the
additional alt keypress is meaningful.
To prevent this, we intelligently emit '<alt>+<control>' instead by sandwiching the
'<alt up>' event like so: '<control down> <alt up> <control up>'
The full sequence thus becomes:
<alt down>
<control down>
<alt up>
<control up>
<x down>
<x up>
e.g
alt = layer(A) -> alt = layer(alt)
Additionally, left hand modifier names are shorthand
for both associated keycodes as opposed to just
the left one.
e.g:
control = esc
is equivalent to:
leftcontrol = esc
rightcontrol = esc