Repository navigation
Conversation
The global event tap is synchronous, so every observed event costs a WindowServer round trip through LinearMouse. It observed all *MouseDragged events unconditionally, which makes click-and-drag stutter with 4000-8000 Hz mice even when no feature can consume those events. Derive the tap's event mask from the configuration instead: drag events are only observed for buttons that button mappings, primary/secondary button switching, universal back/forward, auto scroll or gesture can watch while held, and the tap is recreated when the required set changes. Fixes linearmouse#1380 Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Thanks for investigating this. The optimization makes sense as a workaround, although the performance issue still remains when these features are actually in use. There is also a correctness issue in More generally, |
Enable motion events only while needed by configuration or active interactions. Skip unrelated transformer work and update the Auto Scroll indicator at 60 Hz. Validated with 966 unit tests and manual testing. Supersedes #1381. Related to #1380 and #915. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Performance** * Reduced unnecessary pointer-motion event processing, which may improve responsiveness during mouse movement and dragging. * **Bug Fixes** * Improved event tap recovery and interaction handling, including maintaining button releases during overlapping interactions. * **Testing** * Added coverage for pointer-motion handling, deferred events, and performance. * Isolated test configuration from personal settings when running the test suite. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
Closing this in favor of #1412. |
Fixes #1380
Problem
GlobalEventTapobservesEventType.all, which unconditionally includesleftMouseDragged,rightMouseDraggedandotherMouseDragged. The tap is a synchronous.defaultTapat the HID level, so WindowServer has to round-trip every one of those events through LinearMouse before delivering it. With a 4000–8000 Hz mouse that is up to 8000 blocking round trips per second while a window is being dragged, and dragging stutters visibly (plain pointer movement is fine becausemouseMovedis not observed). Quitting LinearMouse makes it smooth again instantly.In many configurations nothing can consume drag events at all — only pointer/scrolling settings are in use — so observing them is pure overhead.
Change
EventType.required(for: schemes)derives the tap's event mask from the configuration:*MouseDraggedis only observed for buttons that some scheme can actually watch while held: trigger buttons ofbuttons.mappings(includingsimultaneous/whileHeld), left + right whenswitchPrimaryButtonAndSecondaryButtonsis on, back/forward foruniversalBackForward, and theautoScroll/gesturetrigger buttons (defaulting to the middle button, matching the transformers);mouseMovedfollows the existing rule (redirectsToScroll,autoScroll,gesture).GlobalEventTapsubscribes toConfigurationState.$configurationand recreates the tap when the required set changes (debounced, on the main run loop). As a side effect, enablingautoScroll/gesture/redirectsToScrollnow starts observingmouseMovedwithout restarting the app.log show.The mask is still global (one tap), so a mapping on button 3 for one device keeps
otherMouseDraggedobserved for all devices — exactly what happens today for those buttons; the change only ever removes drag types that no feature could consume.Testing
xcodebuild test: 841 tests, 0 failures.CGGetEventTapListshows the tap mask going from0xe401cdeto0xe401c1e(leftMouseDragged/rightMouseDraggeddropped,otherMouseDraggedkept because of the button 2/3 mappings).maincurrently needs the Xcode 26 SDK because ofglassEffectinSecondaryButtonStyle.swift; I built and ran the tests with Xcode 16.4 by stubbing that single line locally (not part of this PR).🤖 Generated with Claude Code