Skip to content

feat: add mouse button 4 and 5 options#96

Open
NazarenoCavazzon wants to merge 2 commits into
AprilNEA:masterfrom
NazarenoCavazzon:feat/button-4-and-5-option
Open

feat: add mouse button 4 and 5 options#96
NazarenoCavazzon wants to merge 2 commits into
AprilNEA:masterfrom
NazarenoCavazzon:feat/button-4-and-5-option

Conversation

@NazarenoCavazzon

Copy link
Copy Markdown

Summary

Adds two new bindable actions — Back (Button 4) and Forward (Button 5) — that emit the real extra mouse-button events the OS and browsers interpret as back/forward natively, rather than synthesizing the ⌘[ / ⌘] keyboard shortcuts that BrowserBack/BrowserForward use.

Motivation

There was previously no way to bind a button to the actual mouse button4/button5 back/forward events. BrowserBack/BrowserForward send ⌘[ / ⌘], which many apps don't honor. Chrome and most macOS apps respond to the physical button4/5 instead — so this exposes that behavior as a first-class action.

BrowserBack/BrowserForward are left unchanged, so this is purely additive and non-breaking. The two new actions live in the Mouse section of the action picker, next to Left/Right/Middle Click.

Changes

  • openlogi-core — new Action::MouseBack / Action::MouseForward variants, wired into label(), category() (→ Category::Mouse) and catalog(). execute_macos() dispatches to a new post_other_button(n) helper that synthesizes an OtherMouse event with an overridden MOUSE_EVENT_BUTTON_NUMBER (3 = back, 4 = forward).
  • openlogi-hook — the event tap now skips any event carrying our SYNTHETIC_EVENT_USER_DATA sentinel, so synthesized button4/5 events aren't re-translated back into Back/Forward presses.
  • openlogi-gui — is_native_click treats (Back, MouseBack) / (ive pass-through, letting the genuine hardware button flowstraight to the OS instead of being suppressed and re-synthesized.
  • locales — app.yml translations for both labels across all f

Recursion guard

Synthesized events are posted at the HID tap location, so Ope Back → MouseBack binding would otherwise loop forever. Everysynthesized mouse event is now stamped with a EVENT_SOURCE_USER_DATA sentinel that the tap recognizes and ignores. This also closes a latent re-entrancy
hole for MiddleClick synthesis.

Testing

  • cargo fmt --all -- --check ✓
  • cargo clippy --workspace --all-targets -- -D warnings ✓
  • cargo test --workspace ✓ (incl. the exhaustive i18n coverag

▎ Note: macOS event synthesis (execute) can't be covered by abuilding and binding a button to each action.

Follow-up (not included)

The default binding for the physical Back/Forward buttons is ard (⌘[). Switching the defaults to the new mouse-buttonactions would make Chrome/Finder back-forward work out of the box, but changes default behavior — left out of this PR by design.

solves: #80

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — Adds two new bindable actions (MouseBack / MouseForward) that synthesize native mouse button 4/5 events instead of the keyboard-based ⌘[ / ⌘] shortcuts, along with a sentinel-based recursion guard.

  • MouseBack / MouseForward actions — new variants added to label(), category(), catalog(), and execute_macos() in binding.rs
  • SYNTHETIC_EVENT_USER_DATA sentinel — stamped on all synthesized mouse events to prevent re-entrancy; retrofitted onto post_click to close a latent MiddleClick re-entrancy hole
  • post_other_button helper — synthesizes OtherMouseDown/OtherMouseUp with overridden MOUSE_EVENT_BUTTON_NUMBER (3 / 4)
  • Recursion guardtranslate() in openlogi-hook returns None for events carrying the sentinel, keeping the event in the stream
  • Native pass-throughis_native_click extended for (Back, MouseBack) / (Forward, MouseForward) so the genuine hardware button signals reach the OS without round-tripping through synthesis
  • i18n — translations for both labels in ja/ru/zh-CN/zh-HK/zh-TW

Pullfrog  | View workflow run | Using Big Pickle (free) (credentials for Anthropic not configured) | 𝕏

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