Skip to content

Add option to prevent pointer movement during gestures - #1372

Closed
romac wants to merge 1 commit into
linearmouse:mainfrom
romac:fix/gesture-button-pointer-suppression
Closed

romac wants to merge 1 commit into
linearmouse:mainfrom
romac:fix/gesture-button-pointer-suppression

Conversation

@romac

@romac romac commented Aug 22, 2026 •

Copy link
Copy Markdown

Closes #1356.

Summary

  • Add a Prevent pointer movement option to the Gesture Button settings.
  • Keep the pointer stationary while the gesture trigger is held.
  • Preserve the current pointer behavior by default.
  • Add configuration schema, localization, and regression test coverage.

Implementation

macOS can move the pointer even when an HID event tap discards a mouseMoved event. When this option is enabled, the gesture transformer discards the event and restores the pointer to its previous location.

This behavior applies while the gesture is tracking and during the cooldown period until the user releases the trigger.

Screenshot

Screenshot 2026-08-22 at 14 24 53

Testing

  • Manually tested the option with an MX Master 3 gesture button.
  • Passed the focused GestureButtonTransformerTests suite.
  • Passed the complete macOS test suite.
  • Built a signed Release archive.
  • Passed strict code-signature verification.
  • Did not run SwiftFormat or SwiftLint because they are not installed.

Copilot AI lite review requested due to automatic review settings August 22, 2026 12:30

Copilot AI 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.

Pull request overview

Adds an opt-in “Prevent pointer movement” setting for Gesture Button handling, allowing LinearMouse to keep the system cursor stationary while a gesture trigger is held (including through the post-gesture cooldown) by warping the pointer back when mouseMoved events are suppressed. This fits into the existing EventTransformer pipeline and configuration system by extending the gesture scheme model, UI state, and transformer behavior, with accompanying schema/localization updates and unit tests.

Changes:

  • Extend gesture configuration (suppressPointerMovement) end-to-end: model Codable, schema (.d.ts + generated JSON), and UI binding.
  • Update GestureButtonTransformer to optionally warp the cursor to counter macOS cursor movement on discarded mouseMoved events, and inject warpPointer for testability.
  • Add/adjust unit tests to cover default behavior and suppression behavior.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
LinearMouseUnitTests/Model/Scheme/Buttons/GestureTests.swift Adds encode/decode regression coverage for suppressPointerMovement.
LinearMouseUnitTests/EventTransformer/GestureButtonTransformerTests.swift Adds tests for default vs suppressed pointer movement and injects warpPointer for verification.
LinearMouseUnitTests/EventTransformer/ButtonMappingTransformerTests.swift Updates initializer call site to pass the new parameter.
LinearMouse/UI/ButtonsSettings/GestureButtonSection/GestureButtonSection.swift Adds the new toggle to Gesture Button settings UI.
LinearMouse/UI/ButtonsSettings/ButtonsSettingsState.swift Adds state binding plumbing for gestureSuppressPointerMovement.
LinearMouse/Model/Configuration/Scheme/Buttons/Gesture/Gesture.swift Adds the new optional config field and Codable support.
LinearMouse/Localizable.xcstrings Adds localized strings for the new toggle title/description.
LinearMouse/EventTransformer/GestureButtonTransformer.swift Implements optional cursor warping while tracking/cooldown; adds warpPointer injection.
LinearMouse/EventTransformer/EventTransformerManager.swift Wires scheme config into the transformer initializer.
Documentation/Configuration.json Adds the generated JSON schema property for the new option.
Documentation/Configuration.d.ts Adds the new option to the TypeScript configuration definition with metadata.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@lujjjh

lujjjh commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the contribution.

Button Mappings now supports swipe gestures, and I plan to move the standalone Gesture Button feature into it. I think preventing pointer movement could be the default behavior when a mapping includes a swipe gesture, rather than a separate option.

A pull request implementing this behavior in Button Mappings would be welcome.

@lujjjh lujjjh closed this Sep 19, 2026
lujjjh added a commit that referenced this pull request Oct 3, 2026
Keep the pointer stationary while a swipe mapping is pending and until
its buttons are released, without affecting direction detection.

Supersedes #1372, which covered pointer locking for Gesture Button only.

Includes regression tests for recognition, release, cancellation, and
concurrent buttons.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Pointer movement is held in place while mapped swipe gestures are
being recognized, preventing the cursor from drifting during a swipe.
* The pointer returns to normal movement when the gesture ends, is
canceled, or times out. Clicks from unrecognized swipes remain anchored
to the original pointer position.
* When multiple mapped buttons are active, the pointer remains anchored
until all relevant buttons are released. Movement deltas are preserved
even when reported pointer coordinates conflict.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

Option to prevent mouse movement when performing gestures

3 participants