Skip to content

fix(macos): preserve Fn semantics for page navigation#429

Open
devsaddle wants to merge 1 commit into
AprilNEA:masterfrom
devsaddle:fix/macos-fn-page-navigation
Open

fix(macos): preserve Fn semantics for page navigation#429
devsaddle wants to merge 1 commit into
AprilNEA:masterfrom
devsaddle:fix/macos-fn-page-navigation

Conversation

@devsaddle

@devsaddle devsaddle commented Jul 19, 2026

Copy link
Copy Markdown

Summary

Add macOS Fn/Globe support to custom shortcuts and reproduce the native navigation-key event representation. This makes synthesized page navigation match physical Fn+Up/Fn+Down instead of producing the shorter scroll behavior seen with flagged arrow-key events.

Changes

  • openlogi-core
    • add KeyCombo::MOD_FN as modifier bit 0x10
    • render Fn before the standard macOS modifier symbols and render common navigation keys in generated shortcut labels
    • cover combined Fn modifier labels and TOML round trips
  • openlogi-inject
    • map MOD_FN to CGEventFlagSecondaryFn on macOS
    • normalize Fn+Left/Right/Up/Down to Home/End/Page Up/Page Down virtual key codes while preserving CGEventFlagSecondaryFn
    • cover explicit Fn shortcuts and Page Up/Page Down compatibility behavior
  • documentation and examples
    • document the modifier mask and Fn+arrow TOML configuration
    • include the Fn bit in the injection example help

Testing

  • cargo fmt --all -- --check
  • cargo test -p openlogi-core -p openlogi-inject --locked (99 core tests, 4 inject tests)
  • cargo clippy -p openlogi-core -p openlogi-inject --all-targets --locked -- -D warnings
  • cargo test --workspace --exclude openlogi-gui --locked
  • cargo clippy --workspace --all-targets --locked -- -D warnings reached the GPUI macOS shader build and was blocked by the local Xcode installation missing the optional Metal Toolchain
  • Hardware validated with an MX Master 2S: Page Up/Page Down in Safari and explicit Fn+Up/Fn+Down in Chrome both scroll a full page; Fn+Left/Fn+Right are covered by unit tests but were not runtime-tested on hardware

Related to #101.

@devsaddle
devsaddle force-pushed the fix/macos-fn-page-navigation branch from 8eb6392 to ef1e743 Compare July 19, 2026 17:31
@devsaddle
devsaddle marked this pull request as ready for review July 19, 2026 17:31
@greptile-apps

greptile-apps Bot commented Jul 19, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds macOS Fn/Globe modifier support to the custom-shortcut system. It introduces MOD_FN (bit 0x10) in openlogi-core, updates rendered_label to display fn first and recognize navigation key codes, and extracts a custom_shortcut_event helper in openlogi-inject that remaps MOD_FN + Arrow to the correct Home/End/Page Up/Page Down virtual key codes with CGEventFlagSecondaryFn, matching the events a physical Fn+arrow key press produces.

  • MOD_FN bit added to KeyCombo, with label rendering, TOML round-trip, and modifier-ordering tests.
  • custom_shortcut_event centralizes flag and key-code translation; Fn+Up/Down → Page Up/Down and Fn+Left/Right → Home/End are both mapped with SecondaryFn.
  • Direct Page Up/Down shortcuts (no MOD_FN) auto-receive SecondaryFn; the analogous Home/End path is currently omitted from that condition.

Confidence Score: 5/5

Safe to merge — the core Fn+Arrow to Page Up/Page Down flow is well-tested and handles all four arrow directions correctly.

The Fn+Arrow remapping and SecondaryFn flag logic are thoroughly tested and hardware-validated. The only gap is that direct Home/End key code shortcuts do not get SecondaryFn added automatically unlike Page Up/Down, but this affects only a manually-authored edge case not covered by the docs and does not regress any existing functionality.

The SecondaryFn condition in crates/openlogi-inject/src/inject/macos.rs is worth a second look to decide whether Home/End should be treated consistently with Page Up/Down.

Important Files Changed

Filename Overview
crates/openlogi-core/src/binding.rs Adds MOD_FN constant (0x10), prepends fn first in rendered_label, and extends the key_code match table with navigation keys. Tests cover isolated Fn, combined-modifier ordering, and TOML round-trip.
crates/openlogi-inject/src/inject/macos.rs Extracts custom_shortcut_event helper that translates MOD_FN+Arrow to Home/End/Page Up/Page Down virtual keys with CGEventFlagSecondaryFn. Direct Page Up/Down key codes also get SecondaryFn; Home/End are omitted from that same auto-flag condition.
crates/openlogi-inject/examples/inject_action.rs Usage string updated to document 0x10=Fn (macOS) modifier bit — one-line docs change, no logic touched.
docs/CONFIGURATION.md Documents the Fn modifier mask (16) with TOML examples for Fn+Up/Down, and notes Page Up/Down auto-SecondaryFn behavior — accurate and consistent with the implementation.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[CustomShortcut combo] --> B{MOD_FN set?}
    B -->|Yes| C{Is key an arrow?}
    C -->|Up 0x7E| D[Remap to PAGE_UP 0x74]
    C -->|Down 0x7D| E[Remap to PAGE_DOWN 0x79]
    C -->|Left 0x7B| F[Remap to HOME 0x73]
    C -->|Right 0x7C| G[Remap to END 0x77]
    C -->|other| H[Keep key_code as-is]
    D --> I[Add SecondaryFn flag]
    E --> I
    F --> I
    G --> I
    H --> I
    B -->|No| J{key_code is Page Up or Page Down?}
    J -->|Yes| K[Add SecondaryFn flag]
    J -->|No| L[No SecondaryFn flag]
    I --> M[post_key with final key and flags]
    K --> M
    L --> M
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[CustomShortcut combo] --> B{MOD_FN set?}
    B -->|Yes| C{Is key an arrow?}
    C -->|Up 0x7E| D[Remap to PAGE_UP 0x74]
    C -->|Down 0x7D| E[Remap to PAGE_DOWN 0x79]
    C -->|Left 0x7B| F[Remap to HOME 0x73]
    C -->|Right 0x7C| G[Remap to END 0x77]
    C -->|other| H[Keep key_code as-is]
    D --> I[Add SecondaryFn flag]
    E --> I
    F --> I
    G --> I
    H --> I
    B -->|No| J{key_code is Page Up or Page Down?}
    J -->|Yes| K[Add SecondaryFn flag]
    J -->|No| L[No SecondaryFn flag]
    I --> M[post_key with final key and flags]
    K --> M
    L --> M
Loading

Reviews (2): Last reviewed commit: "fix(macos): preserve fn page navigation" | Re-trigger Greptile

Comment thread crates/openlogi-core/src/binding.rs Outdated
Comment thread crates/openlogi-inject/src/inject/macos.rs
@devsaddle
devsaddle force-pushed the fix/macos-fn-page-navigation branch from ef1e743 to 9e46e7e Compare July 20, 2026 09:54
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.

1 participant