hex/src/windows/input/disposition.rs
Dax e4d85b44aa
windows: join back-to-back dictations with a space (#1980)
* windows: join back-to-back dictations with a space

move the input-activity revision, continuation join and its tests into a
platform-neutral continuation module. windows now invalidates it on real
keys and clicks from the low-level hooks and on foreground-window changes,
and the paster joins dictation and paste last the way macos does.

* windows: end continuations on real input and skip hex's own trigger

injected input from other tools and the auxiliary mouse buttons end a paste
continuation as on macOS, while Hex's own synthetic events and a dictation
trigger that Labs › Share shortcut lets through do not. A standalone macOS
paste clears the continuation only where dev did: at the start of typing, or
after the clipboard is preserved and checked.

* windows: a bare trigger key press ends the paste continuation

Labs › Share shortcut lets the dictation trigger's key reach the app in
front, and the hook treated every event for that key as hex's own. A
plain Space while Ctrl+Space is bound then kept the continuation, so the
next dictation joined with a space for no reason. Mark the press as the
shortcut's only once it claims the capture, and drive the hook's own
state machine in a test.
2026-11-18 19:28:07 -05:00

54 lines
1.6 KiB
Rust
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//! What each low-level hook decided for one event, and whether one of Hex's
//! own shortcuts caused it.
use super::Disposition;
use super::activity;
/// What a hook decided for one event, and whether one of Hex's own shortcut
/// triggers sent it.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(super) struct Handled {
pub(super) disposition: Disposition,
trigger: bool,
}
impl Handled {
/// An event no shortcut claimed.
pub(super) const PASS: Self = Self {
disposition: Disposition::Pass,
trigger: false,
};
/// An event one of Hex's shortcut triggers caused, whatever the hook did
/// with it. Labs › Share shortcut lets the dictation trigger's key reach
/// the app, and that press is Hex's, not the user's typing.
pub(super) const fn own(disposition: Disposition) -> Self {
Self {
disposition,
trigger: true,
}
}
/// An event the hook decided for, `trigger` saying whether one of Hex's
/// shortcut triggers caused it.
pub(super) const fn new(disposition: Disposition, trigger: bool) -> Self {
Self {
disposition,
trigger,
}
}
/// Whether the event is the user's own typing or clicking, which ends a
/// paste continuation: it reached the app in front, and no shortcut of
/// Hex's triggered it.
pub(super) fn ends_continuation(
self,
is_down: bool,
modifier: bool,
extra_info: usize,
) -> bool {
self.disposition == Disposition::Pass
&& !self.trigger
&& activity::ends_continuation(is_down, modifier, extra_info)
}
}