fix(mouse-enhancer): middle-click stops working after app restart - #205
Draft
ayangweb wants to merge 1 commit into
Draft
fix(mouse-enhancer): middle-click stops working after app restart#205ayangweb wants to merge 1 commit into
ayangweb wants to merge 1 commit into
Conversation
…umeration at startup (#1)
Collaborator
Author
|
@ggbond268 copilot 修复的,需要你来测试 |
ayangweb
marked this pull request as draft
July 19, 2026 04:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixed #202
After each app or system restart, the simulate-middle-click feature is silently broken until the user toggles its switch off and back on.
Two defects in
MouseEnhancerMiddleClickSession:1. CGEvent tap not re-enabled when macOS auto-disables it
macOS can send
tapDisabledByTimeout/tapDisabledByUserInputto a non-listencghidEventTapduring busy startup or after sleep. The tap callback did not handle these events, so the tap stayed disabled permanently.MouseEnhancerSession(scroll reversing) already has this recovery; add the same to the middle-click session:2. MTDeviceCreateList returns empty at login-item startup
When the app launches as a login item at boot,
MultitouchSupport.frameworkmay not have finished enumerating devices yet, so_mtDeviceCreateList()returns an empty array and no touch listeners are registered. The existing IOKitkIOFirstMatchNotificationrecovery does not help here—it drains currently-present devices on registration (arming future arrivals) but never fires a callback for devices already in the IOKit registry. Result: no touch data,threeDownnever set, middle-click silently dead.Schedule a one-shot 3-second rebuild at the end of
start()when no devices are found, mirroring the existing wake-restart recovery:Tests
Added
testMiddleClickStartsOnActivateWhenSavedAsEnabledAndAccessibilityGrantedandtestMiddleClickDoesNotStartOnActivateWhenAccessibilityDeniedto cover theactivate()path (app-restart scenario) with pre-persisted settings, which had no test coverage.