Fix: Implement device polling for late-connecting multitouch devices …#109
Merged
NullPointerDepressiveDisorder merged 4 commits intomainfrom Feb 16, 2026
Merged
Fix: Implement device polling for late-connecting multitouch devices …#109NullPointerDepressiveDisorder merged 4 commits intomainfrom
NullPointerDepressiveDisorder merged 4 commits intomainfrom
Conversation
…and update UI notifications
Copilot started reviewing on behalf of
NullPointerDepressiveDisorder
February 15, 2026 08:59
View session
Contributor
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves MiddleDrag’s reliability when multitouch hardware (e.g., Bluetooth trackpads) connects after app launch by adding a device polling/backoff mechanism in MultitouchManager, updating the menu UI to reflect late connections/timeouts, and extending test coverage for the new polling behavior.
Changes:
- Add device polling with exponential backoff + timeout when no multitouch hardware is available at start/restart, exposing
isPollingForDevicesand posting UI notifications. - Update menu/status messaging and app logging to reflect polling/late connections/timeouts.
- Add new unit tests for polling state transitions and constants; refine some logging/concurrency annotations.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| MiddleDrag/UI/MenuBarController.swift | Observes new device/polling notifications and shows “Waiting for Trackpad…” state in the status menu. |
| MiddleDrag/MiddleDragTests/MultitouchManagerTests.swift | Adds polling-focused unit tests (start/stop/double-start/toggle/constants). |
| MiddleDrag/Managers/MultitouchManager.swift | Implements polling/backoff/timeout flow, exposes polling state, integrates with start/stop/restart/toggle. |
| MiddleDrag/Core/MouseEventGenerator.swift | Adjusts logging calls and adds unsafe annotations for some CoreGraphics interactions/global state. |
| MiddleDrag/AppDelegate.swift | Logs when the app starts in polling mode (no device at launch). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…date related tests
…al access and add corresponding unit tests
…nit tests for connection logic
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.
This pull request adds robust support for polling and connecting to multitouch devices (such as Bluetooth trackpads) that may not be present at app launch, improving reliability on systems where devices connect after boot or wake. It introduces a device polling mechanism with exponential backoff, user feedback, and comprehensive tests to ensure correct behavior. Additionally, it refines logging and improves safety annotations in the codebase.
Device polling and connection improvements:
MultitouchManagerthat periodically checks for newly connected multitouch devices when none are found at launch, using exponential backoff and a maximum timeout. The polling state is exposed viaisPollingForDevices, and user actions (such as toggling enabled state) now interact correctly with polling. [1] [2] [3] [4] [5] [6] [7] [8] [9]AppDelegateto log when the app is polling for device connections, providing clearer feedback to users.Testing enhancements:
MultitouchManagerTeststo verify polling behavior, including starting, stopping, double-start prevention, toggling, and constant values. [1] [2] [3]Logging and code safety:
unsafestring interpolation in logging calls. [1] [2]unsafeannotations to certain Core Graphics function calls and variable accesses inMouseEventGeneratorto clarify thread-safety and code intent. [1] [2] [3]…and update UI notifications