Skip to content

🐞 Track physical Fn state so media keys don't trigger Loop - #1184

Draft
root-daemon wants to merge 1 commit into
mrkai77:developfrom
root-daemon:bugfix/1139-fn-flag-media-keys
Draft

root-daemon wants to merge 1 commit into
mrkai77:developfrom
root-daemon:bugfix/1139-fn-flag-media-keys

Conversation

@root-daemon

Copy link
Copy Markdown

Description

macOS adds the Fn flag to volume and brightness keys (as well as arrows and F-keys) even when Fn isn't held. KeybindTrigger decided whether to keep the Fn flag on arrow/F-keys by looking at the previous event's flags, so after a media key press the next arrow key looked like Globe + Arrow and opened Loop with the matching action.

As suggested in the issue, this tracks Fn's physical state separately in a small FnKeyState helper:

  • Fn is only considered held after a flagsChanged event for the Fn key itself.
  • Any event without the Fn flag clears it, in case a release was missed.

Only the existing isFnSpecialKey keys have the flag stripped, so other keys behave as before.

Fixes #1139

How has this been tested?

  • Added FnKeyStateTests (media key → arrow, real Fn + arrow, Fn release, missed release, other modifiers while holding Fn, non-special keys). All pass.
  • Existing KeybindResolverTests pass.
  • Manually on a built-in keyboard, Globe as trigger: pressed volume/brightness, then an arrow key: Loop no longer opens.
  • Manually: Globe + arrow still triggers the expected action, and Globe alone still opens the radial menu.

Note: on develop, the test target doesn't compile because CycleProgressStoreTests.swift uses APIs that no longer exist, and CycleActionCoordinatorTests.selectingCurrentFromOutsideResumesStoredProgress fails. Both happen without this change; I set that file aside locally to run the suite.

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in this PR.

Please describe to which degree, if any, an LLM was used in creating this pull request.

I used Claude Code (Anthropic's Claude Opus 5.5) to find the root cause, write the FnKeyState change and its unit tests, and draft this description. The unit tests have been run. My own review of the code and the manual checks above are still pending, which is why this is a draft; I'll mark it ready for review once both are done on my Mac.

🤖 Generated with Claude Code

macOS adds the Fn flag to volume/brightness keys, and KeybindTrigger used
the previous event's flags to decide whether Fn was held for arrow and
F-keys. A media key press therefore made the next arrow key look like
Globe + Arrow and opened Loop. Fn is now only considered held after a
flagsChanged event for the Fn key itself.

Fixes mrkai77#1139

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐞 Loop triggered by sound or brightness keys

1 participant