Repository navigation
Conversation
Fixes #303. When hold-to-talk is bound to Fn, FreeFlow consumed every Fn flagsChanged event at its CGEvent tap, so macOS never saw the key and 'Press globe to: Change Input Source' (or any system Globe action) could never fire -- even for quick taps far too short to be push-to-talk. Two changes: - ShortcutMatcher: Fn/Globe (keyCode 63) modifier events are no longer consumed on behalf of the hold binding. macOS ignores long Fn holds, so hold-to-talk works identically by passive observation, while quick taps now reach the system Globe action. Toggle bindings (e.g. the default Cmd+Fn) keep consuming, since a Fn tap is meaningful on both sides there. - AppState: hold-to-talk on Fn gains a 200 ms minimum hold time (max of the user's Shortcut Start Delay and the floor), so a quick tap released before the floor cancels the pending start instead of flashing a recording. Updated testBareFnHoldLifecycle for the new passthrough semantics and added coverage for Fn toggle consumption and the default hold=Fn / toggle=Cmd+Fn interaction. make check passes.
- ShortcutMatcher: a snapshot that only flips Fn hold state (e.g. a repaired missing Fn state after the event tap was re-enabled) no longer marks the carrying ordinary key event for consumption, so GlobalShortcutBackend can't drop that keystroke. Toggle and non-Fn hold transitions keep consuming as before. Regression test added. - ModifierKeyEventState.fnKeyCode now aliases ShortcutBinding.fnKeyCode so event production and shortcut matching share one source of truth.
Move the Fn hold-to-talk 200 ms start floor into ShortcutStartDelayPolicy so it can be tested: Fn holds get the floor, longer user delays are kept, and non-Fn and toggle starts keep the configured delay. Fn presses pass through to macOS so quick taps reach the Globe action. With double-tap to lock enabled, the second press that latches recording and the press that stops a locked recording now belong to FreeFlow and are consumed for their whole down/up pair. The first tap still reaches macOS, since it is indistinguishable from an ordinary Globe tap when it happens. Co-authored-by: Fox Qi <1661407+foxswat@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #303
Supersedes #304 — based on work by @foxswat (original commits cherry-picked with authorship preserved).
User-facing fix
When Hold to Talk is set to Fn, FreeFlow swallowed every Fn/Globe key event. macOS never saw the key, so Press 🌐 key to → Change Input Source / Show Emoji & Symbols stopped working while FreeFlow ran, even for quick taps.
Now, with Hold to Talk = Fn:
How it works
ShortcutMatcher: bare Fn events no longer get consumed on behalf of the hold binding, so macOS sees them. Toggle bindings that use Fn still consume. When a snapshot only repairs a missed Fn hold state, it passes through, so the ordinary key event that carries it isn't dropped.max(userDelay, 0.2)). A tap released before then cancels the pending start through the existing path. Longer user delays are kept. Non-Fn bindings and toggle starts keep their configured delay.DictationShortcutSessionController.claimsHoldShortcutPressesis true while the controller waits for the second press, and while a recording is locked by double tap.HotkeyManagerreads it when each new Fn press starts. A claimed press is consumed for both its down and up events, and an unclaimed one passes through for both. macOS never sees half a press.Changes vs #304
main, including Add double-tap on the hold shortcut to lock recording #349's double-tap lock.CHANGELOG.mdedit, as the maintainer asked.AppStateintoShortcutCore/ShortcutStartDelayPolicy.swiftso tests can cover it deterministically, as the maintainer asked. It's added toTEST_PRODUCTION_SOURCES.DictationShortcutSessionController.beginManualis untouched (Stop a menu-bar toggle session on the first shortcut press #360 edits it).Tests
make checkandgit diff --checkpass.testBareFnHoldLifecyclewas updated, and these came from Let macOS Globe actions work when hold-to-talk is Fn #304:testBareFnToggleStillConsumes,testFnHoldPassthroughUnlessToggleComboActive,testSnapshotRepairFnHoldDoesNotConsume.testFnHoldStartDelayPolicy: Fn gets the 200 ms floor, longer user delays are kept, Fn-as-modifier bindings get the floor, and non-Fn, toggle and disabled bindings keep their delay.testQuickFnTapCancelsPendingStart: a release before the floor ends the session with.stop, which cancels the pending start.testClaimedFnPressDecisionIsStickyPerPress: the decision made on Fn down also applies to that press's Fn up. Non-Fn hold keys are unaffected.testBackendResetClearsFnClaimtestFnDoubleTapLockClaimsOnlyFollowUpPresses: runs the matcher and controller end to end. The first tap passes through; the latching press and the stop press are consumed; the next ordinary tap passes through.testFnQuickTapPassesThroughWithDoubleTapEnabled: a single tap passes through and times out without recording, and a long hold passes through.Manual test: pending
These need an Apple keyboard with a Globe key. Use invented speech only and put no private content in the report. Record the macOS version and the Globe system action you set.
Shortcut risk notes
AppStatethroughDispatchQueue.main.async, which runs well before a human's second press arrives.🤖 Generated with Claude Code