Skip to content

Fix right-click fallback for button gesture mappings - #1352

Merged
lujjjh merged 1 commit into
mainfrom
fix/button-mapping-fresh-click-replay
Aug 10, 2026
Merged

lujjjh merged 1 commit into
mainfrom
fix/button-mapping-fresh-click-replay

Conversation

@lujjjh

@lujjjh lujjjh commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Rebuild completed button-mapping fallback clicks as fresh CGEvent instances instead of replaying the buffered physical events.
  • Replay the click after the current Event Tap callback and post it through the HID event tap.
  • Deliver mouse-up asynchronously 15 ms after mouse-down, giving applications an observable pressed state without blocking the Event Tap thread.
  • Drop sub-threshold drag events while preserving the original button, location, flags, and click state.
  • Prevent replayed events from being processed by the primary/secondary button swap transformer a second time.

Background

When a mouse button is configured as a gesture trigger, its down, drag, and up events are buffered until the gesture is resolved. If movement remains below the gesture threshold, the interaction should fall back to a normal click.

Previously, the buffered event objects were replayed together through the session event tap. This worked in most applications, but right-click fallback could be ignored by applications such as Messages.

The fallback now creates a new semantic click after the original callback has completed. Mouse-down and mouse-up are created at their respective delivery times and separated by a non-blocking 15 ms interval.

Incomplete buffered streams used by chord and remap handling continue to use the existing replay path.

Testing

  • Verified right-click context menus in Messages with a right-button drag gesture mapping configured.
  • Added coverage confirming that fallback clicks:
    • are delivered after the original callback
    • use newly created mouse-down and mouse-up events
    • omit buffered sub-threshold drag events
    • preserve click metadata
    • separate mouse-down and mouse-up by 15 ms
  • All 558 unit tests pass.
  • SwiftFormat and strict SwiftLint pass for the changed files.
  • git diff --check

@lujjjh lujjjh added the bug Something isn't working label Aug 10, 2026
@lujjjh
lujjjh merged commit d9255c2 into main Aug 10, 2026
1 check passed
@lujjjh
lujjjh deleted the fix/button-mapping-fresh-click-replay branch August 10, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant