Skip to content

Fix cursor jumping back after dragging a button used in mappings - #1447

Merged
lujjjh merged 1 commit into
mainfrom
fix/button-mapping-drag-fallback
Oct 10, 2026
Merged

lujjjh merged 1 commit into
mainfrom
fix/button-mapping-drag-fallback

Conversation

@lujjjh

@lujjjh lujjjh commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1441.

Releasing a mouse button after dragging could move the cursor back to its starting position when the button was used in a mapping, such as holding middle-click to scroll for volume control. The fallback converted the buffered drag into a click at the original position.

Only synthesize a fallback click when every buffered event stays at the same position. Otherwise, replay the original events to preserve the drag. Stationary clicks and pointer-anchored swipe fallbacks retain the existing click delivery behavior.

Validation:

  • All 81 button mapping transformer tests pass.
  • Added coverage for small and large movements, including returning to the starting position.
  • SwiftFormat, strict SwiftLint, and git diff --check pass.
  • The user confirmed manual testing is complete.

Assisted by OpenAI Codex.

Preserve buffered pointer movement instead of collapsing moved fallback streams into clicks at their starting position. Keep fresh click delivery for stationary input and anchored swipe fallbacks.

Co-authored-by: Codex <[email protected]>
@lujjjh lujjjh added the bug Something isn't working label Oct 10, 2026
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: linearmouse/linearmouse/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 95894a9d-0243-4b23-844c-a36b3c93c376

📥 Commits

Reviewing files that changed from the base of the PR and between d96e57e and b6d1dc0.


📒 Files selected for processing (2)
  • LinearMouse/EventTransformer/ButtonMappingTransformer.swift
  • LinearMouseUnitTests/EventTransformer/ButtonMappingTransformerTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.



📝 Walkthrough

Walkthrough

The button mapping transformer now creates a synthetic-click request only when the button-up and intervening matching drag events remain at the button-down location. Tests cover replay of moved held-wheel interactions and deferred replay with a swipe mapping.

Changes

Button mapping fallback

Layer / File(s) Summary
Qualify synthetic-click fallbacks
LinearMouse/EventTransformer/ButtonMappingTransformer.swift, LinearMouseUnitTests/EventTransformer/ButtonMappingTransformerTests.swift
The transformer checks pointer locations before creating a synthetic-click request. Tests verify that held-wheel interactions with pointer movement replay the original events without a synthetic click. The deferred replay test now uses a rightward swipe mapping.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium


Merge Risk: ⚪ Minimal · up to b6d1d

The change addresses cursor snap-back while preserving stationary-click and anchored-swipe fallback behavior. No actionable merge-blocking risk is established.

Pre-merge checks | Passed 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the main change: preventing the cursor from jumping back after dragging with a mapped button.
Description check Passed The description directly explains the cursor-jumping issue, the fallback behavior change, validation results, and test coverage.
Linked Issues check Passed Issue #1441 requires that a mapped middle-button drag must not move the cursor back to its start on release. The production change in ButtonMappingTransformer.swift requires the button-up and all ma…
Out of Scope Changes check Passed The pull request changes only the fallback decision in ButtonMappingTransformer.swift and adds focused transformer tests. The production change directly addresses the mapped-button drag behavior in …

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR


🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@lujjjh
lujjjh merged commit 6f8d736 into main Oct 10, 2026
2 checks passed
@lujjjh
lujjjh deleted the fix/button-mapping-drag-fallback branch October 10, 2026 15:24
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.

Cursor snaps back after holding middle button and dragging when middle-button is used by Button Mapping

1 participant