Repository navigation
Auto Scroll keeps scrolling the window it started in after the cursor leaves it - #1482
Conversation
Auto Scroll posted its scroll events to the session event tap, so they went to whatever was under the cursor and stopped reaching the original window once the pointer left it. Resolve the window under the anchor when Auto Scroll starts and post each event directly to its process, stamped with the window number and the window-local anchor so the app routes it to the view that was under the anchor. Keep the cursor-following path for accessory apps, LinearMouse's own windows, and systems where the private CGEventSetWindowLocation symbol is unavailable. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Window hit data and target posting LinearMouse/WindowFocus/WindowFocus.swift, LinearMouse/EventTransformer/AutoScrollScrollTarget.swift |
Window hit-testing returns the target and its window-local coordinates. The scroll target records the process, window, and locations, then sets event location and window fields before posting to the target process. |
Activation location and event routing LinearMouse/EventTransformer/AutoScrollTransformer.swift, LinearMouse/EventTransformer/EventTransformerManager.swift, LinearMouseUnitTests/EventTransformer/AutoScrollTransformerTests.swift |
Activation paths pass a target location to the resolver. The transformer retains a resolved target during activation and uses it to post scroll events, with the existing event sink as fallback. The manager supplies the resolver, and a test checks the trigger location. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant AutoScrollTransformer
participant AutoScrollScrollTarget
participant WindowFocus
participant TargetApplicationProcess
participant FallbackEventSink
AutoScrollTransformer->>AutoScrollScrollTarget: Resolve target at activation location
AutoScrollScrollTarget->>WindowFocus: Request window hit
WindowFocus-->>AutoScrollScrollTarget: Return target and local point
AutoScrollScrollTarget-->>AutoScrollTransformer: Return resolved target
alt Target is available
AutoScrollTransformer->>AutoScrollScrollTarget: Post generated scroll event
AutoScrollScrollTarget->>TargetApplicationProcess: Set event fields and post
else Target is unavailable
AutoScrollTransformer->>FallbackEventSink: Post generated scroll event
end
Possibly related PRs
- linearmouse/linearmouse#1480: Changes Logitech activation anchor coordinates in the same activation paths that provide the location for target resolution.
Suggested labels: bug
Merge Risk: 
Minimal · up to 74871
-
No concrete merge-blocking issue was established.
Pre-merge checks: 
4
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
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Partially addresses #1362 (scrolling stops when the cursor moves outside the app).
Problem
Auto Scroll posted its scroll events to the session event tap. Those go to whatever is under the cursor, so as soon as the pointer left the window where Auto Scroll started (for example, onto the menu bar or another app), scrolling stopped or moved to a different window. Setting the event location doesn't help: posting a located event to the session tap warps the cursor.
Changes
SLSFindWindowAndOwner, already used byWindowFocus), along with the anchor in window-local coordinates.CGEvent.postToPid, stamped with:NSEvent.windowNumber) and fields 91/92;CGEventSetWindowLocation;Without the window number and window-local location, AppKit drops pid-targeted mouse events. With them, the app hit-tests the anchor, so the scroll goes to the view where Auto Scroll started.
CGEventSetWindowLocationcan't be resolved;WindowFocus.windowHit(at:)now also returns the window-local point;window(at:)is unchanged for existing callers.Behavior change
Scroll events posted to a process don't pass through LinearMouse's own event tap. Auto Scroll output therefore no longer gets the scroll pipeline of the last active device (reverse scrolling, smoothing, acceleration, scroll speed). Auto Scroll's direction comes from the pointer position and its speed from its own setting, so this also stops reverse scrolling from inverting Auto Scroll.
Testing
With the cursor outside the target window:
Also:
Electron apps have not been tested yet; they share Chrome's engine, so they are expected to behave like Chrome.
🤖 Generated with Claude Code