mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-27 07:58:01 +01:00
* take the microphone key at the session tap macos matches its own dictation shortcut before the app and before hex's annotated-session tap, so the mic key never reached the recorder or a binding. with labs › microphone key alone on, a session tap now sees key code 176: the press is fed to the listener when one of hex's shortcuts matches it, and to the window's recorder while a shortcut is being recorded; in both cases the press and its release are consumed. anything else passes through, and with the lab off no tap exists. the recorder reads those presses through the same ChordCapture its own key events use, and the tap wakes the window for them. also fixes a_lone_lab_card_keeps_half_the_row, which had no odd group left after the microphone key card joined the grid. * keep the key-name test with its helper * take the recorder's watch with a question mark * name the recorder wake and take presses without a drain * harden the microphone key tap takes the press from the session boundary handy-keys ships at, with a comment citing its listener. the tap-disable notification now comes first, ends the capture and forgets the press like the annotated tap; the instant is read with the same recency rule as hid events; a failed send passes the event through; the taken press is a single option, cleared when a press passes through, when the tap is removed, and on disable. removing the tap only cancels a capture when it holds a listener press. the screenshot shortcuts refuse the key, since a shot reads its keys after this tap. the recorder clears the queue it no longer reads and feeds tap presses through the monitor's own channel. docs hedge on whether macOS's dictation still opens; a real press is still unobserved on hardware. adds callback tests for bound, unbound, paused, recording, synthetic and disabled cases.
65 lines
2.2 KiB
Rust
65 lines
2.2 KiB
Rust
//! Issue 181: any shortcut on the microphone (dictation) key needs Labs ›
|
||
//! Microphone key alone on macOS, with or without a modifier. macOS's
|
||
//! recorder records the chord and `validate` refuses it before saving, with
|
||
//! the same "Unsupported key" the key gave before.
|
||
//!
|
||
//! The screenshot shortcuts are the exception: Hex reads the microphone key at
|
||
//! its own session tap, before the annotated-session tap the screenshots' keys
|
||
//! go through, so they refuse it however the labs are set.
|
||
//!
|
||
//! Split from `settings.rs` to keep that file under the source cap.
|
||
|
||
use super::*;
|
||
use crate::app_settings::MICROPHONE_KEY_CODE;
|
||
|
||
fn microphone() -> HotkeyKey {
|
||
HotkeyKey {
|
||
code: MICROPHONE_KEY_CODE,
|
||
label: "Mic".into(),
|
||
}
|
||
}
|
||
|
||
#[test]
|
||
fn the_microphone_key_needs_its_labs_toggle() {
|
||
let alone = HotkeyBinding {
|
||
modifiers: HotkeyModifiers::default(),
|
||
key: Some(microphone()),
|
||
};
|
||
let with_control = HotkeyBinding {
|
||
modifiers: HotkeyModifiers::control_option(),
|
||
key: Some(microphone()),
|
||
};
|
||
let dictation_targets = [
|
||
ShortcutTarget::Dictation,
|
||
ShortcutTarget::Cancel,
|
||
ShortcutTarget::PasteLast,
|
||
];
|
||
let mut settings = AppSettings::default();
|
||
for target in dictation_targets {
|
||
for binding in [&alone, &with_control] {
|
||
assert_eq!(
|
||
validate(&settings, target, binding),
|
||
Err(tr("Unsupported key")),
|
||
"{target:?}"
|
||
);
|
||
}
|
||
}
|
||
settings.labs.microphone_key = true;
|
||
for target in dictation_targets {
|
||
for binding in [&alone, &with_control] {
|
||
assert_eq!(validate(&settings, target, binding), Ok(()), "{target:?}");
|
||
}
|
||
}
|
||
// The screenshot shortcuts never take it: a shot reads its keys at the
|
||
// annotated session, after Hex's session tap has already taken the press.
|
||
for target in [ShortcutTarget::Screenshot, ShortcutTarget::ScreenshotRecord] {
|
||
for binding in [&alone, &with_control] {
|
||
assert_eq!(
|
||
validate(&settings, target, binding),
|
||
Err(tr("Unsupported key")),
|
||
"{target:?}"
|
||
);
|
||
}
|
||
}
|
||
assert_eq!(alone.keycaps(), ["Mic"]);
|
||
}
|