@@ -6,55 +6,76 @@ The project has been refactored from two large files into a modular, maintainabl
66
77```
88MiddleDrag/
9- ├── Core/ # Core functionality
10- │ ├── MultitouchFramework.swift # Private API bindings and framework management
11- │ ├── GestureRecognizer.swift # Gesture detection and state management
12- │ └── MouseEventGenerator.swift # Mouse event generation and cursor control
9+ ├── Core/ # Core functionality
10+ │ ├── MultitouchFramework.swift # Private API bindings and framework management
11+ │ ├── GestureRecognizer.swift # Gesture detection and state management
12+ │ ├── MouseEventGenerator.swift # Mouse event generation and cursor control
13+ │ └── TouchDeviceProviding.swift # Protocol for device monitoring/dependency injection
1314│
14- ├── Models/ # Data models
15- │ ├── TouchModels.swift # Touch data structures (MTPoint, MTTouch, etc.)
16- │ └── GestureModels.swift # Gesture state and configuration models
15+ ├── Models/ # Data models
16+ │ ├── TouchModels.swift # Touch data structures (MTPoint, MTTouch, etc.)
17+ │ └── GestureModels.swift # Gesture state and configuration models
1718│
18- ├── Managers/ # Business logic managers
19- │ ├── MultitouchManager.swift # Main coordinator for gesture system
20- │ └── DeviceMonitor.swift # Device monitoring and callback management
19+ ├── Managers/ # Business logic managers
20+ │ ├── MultitouchManager.swift # Main coordinator for gesture system
21+ │ ├── DeviceMonitor.swift # Device monitoring and callback management
22+ │ ├── AccessibilityMonitor.swift # Accessibility permission polling and app handling
23+ │ └── AccessibilityWrappers.swift # Wrappers for accessibility system APIs (testability)
2124│
22- ├── UI/ # User interface
23- │ ├── MenuBarController.swift # Menu bar UI management
24- │ └── AlertHelper.swift # Alert dialogs and user notifications
25+ ├── UI/ # User interface
26+ │ ├── MenuBarController.swift # Menu bar UI management
27+ │ └── AlertHelper.swift # Alert dialogs and user notifications
2528│
26- ├── Utilities/ # Helper utilities
27- │ ├── PreferencesManager.swift # User preferences persistence
28- │ ├── LaunchAtLoginManager.swift # Launch at login functionality
29- │ └── AnalyticsManager.swift # Analytics and telemetry management
29+ ├── Utilities/ # Helper utilities
30+ │ ├── PreferencesManager.swift # User preferences persistence
31+ │ ├── LaunchAtLoginManager.swift # Launch at login functionality
32+ │ ├── AnalyticsManager.swift # Analytics and telemetry management
33+ │ ├── ScreenHelper.swift # Multi-monitor screen coordinate handling
34+ │ ├── SystemGestureHelper.swift # System trackpad settings and process management
35+ │ ├── UpdateManager.swift # App updates via Sparkle framework
36+ │ └── WindowHelper.swift # Window detection under cursor
3037│
31- ├── MiddleDragApp.swift # SwiftUI app entry point
32- ├── AppDelegate.swift # Application delegate
33- ├── Info.plist # App configuration
34- └── MiddleDrag.entitlements # App entitlements
38+ ├── MiddleDragApp.swift # SwiftUI app entry point
39+ ├── AppDelegate.swift # Application delegate
40+ ├── Info.plist # App configuration
41+ └── MiddleDrag.entitlements # App entitlements
3542│
36- MiddleDragTests/ # Unit test target
37- ├── GestureModelsTests.swift # Tests for gesture models
38- ├── GestureRecognizerTests.swift # Tests for gesture recognition logic
39- └── TouchModelsTests.swift # Tests for touch data structures
43+ MiddleDragTests/ # Unit test target
44+ ├── GestureModelsTests.swift # Tests for gesture models
45+ ├── GestureRecognizerTests.swift # Tests for gesture recognition logic
46+ ├── TouchModelsTests.swift # Tests for touch data structures
47+ ├── MouseEventGeneratorTests.swift # Tests for mouse event generation
48+ ├── MultitouchFrameworkTests.swift # Tests for multitouch framework bindings
49+ ├── MultitouchManagerTests.swift # Tests for main coordinator
50+ ├── DeviceMonitorTests.swift # Tests for device monitoring
51+ ├── AccessibilityMonitorTests.swift # Tests for accessibility permissions
52+ ├── MenuBarControllerTests.swift # Tests for menu bar UI
53+ ├── AlertHelperTests.swift # Tests for alert dialogs
54+ ├── PreferencesManagerTests.swift # Tests for preferences persistence
55+ ├── LaunchAtLoginManagerTests.swift # Tests for launch at login
56+ ├── AnalyticsManagerTests.swift # Tests for analytics
57+ ├── ScreenHelperTests.swift # Tests for screen coordinate handling
58+ ├── SystemGestureHelperTests.swift # Tests for system gesture settings
59+ ├── WindowHelperTests.swift # Tests for window detection
60+ └── Mocks/ # Mock objects for testing
61+ └── MockDeviceMonitor.swift # Mock device monitor
4062│
41- .github/ # GitHub configuration
42- ├── workflows/ # CI/CD workflows
43- │ └── *.yml # GitHub Actions workflow files
44- ├── ISSUE_TEMPLATE/ # Issue templates
45- └── copilot-instructions.md # Copilot configuration
63+ .github/ # GitHub configuration
64+ ├── workflows/ # CI/CD workflows
65+ │ └── *.yml # GitHub Actions workflow files
66+ ├── ISSUE_TEMPLATE/ # Issue templates
4667│
4768Root Files:
48- ├── README.md # Project documentation
49- ├── PROJECT_STRUCTURE.md # This file
50- ├── LICENSE # MIT License
51- ├── CODE_OF_CONDUCT.md # Community guidelines
52- ├── CONTRIBUTING.md # Contribution guide
53- ├── SECURITY.md # Security policy
54- ├── build.sh # Build automation script
55- ├── bump-version.sh # Version bump script
56- ├── codecov.yml # Codecov configuration
57- └── .gitignore # Git ignore rules
69+ ├── README.md # Project documentation
70+ ├── PROJECT_STRUCTURE.md # This file
71+ ├── LICENSE # MIT License
72+ ├── CODE_OF_CONDUCT.md # Community guidelines
73+ ├── CONTRIBUTING.md # Contribution guide
74+ ├── SECURITY.md # Security policy
75+ ├── build.sh # Build automation script
76+ ├── bump-version.sh # Version bump script
77+ ├── codecov.yml # Codecov configuration
78+ └── .gitignore # Git ignore rules
5879```
5980
6081## Architecture Benefits
@@ -90,6 +111,7 @@ Root Files:
90111- ** MultitouchFramework** : Interfaces with private Apple framework
91112- ** GestureRecognizer** : Converts touch data into gestures
92113- ** MouseEventGenerator** : Handles all mouse event synthesis
114+ - ** TouchDeviceProviding** : Protocol for device monitoring and dependency injection
93115
94116### Model Layer
95117- ** TouchModels** : Raw touch data structures
@@ -98,6 +120,8 @@ Root Files:
98120### Manager Layer
99121- ** MultitouchManager** : Main coordinator, implements business logic
100122- ** DeviceMonitor** : Manages device lifecycle and callbacks
123+ - ** AccessibilityMonitor** : Manages accessibility permission polling and app handling
124+ - ** AccessibilityWrappers** : Wrappers for system accessibility APIs (enables testability)
101125
102126### UI Layer
103127- ** MenuBarController** : All menu bar UI logic
@@ -107,11 +131,15 @@ Root Files:
107131- ** PreferencesManager** : UserDefaults persistence
108132- ** LaunchAtLoginManager** : System integration for auto-launch
109133- ** AnalyticsManager** : Analytics and telemetry management
134+ - ** ScreenHelper** : Multi-monitor screen coordinate conversion (Cocoa ↔ Quartz)
135+ - ** SystemGestureHelper** : Trackpad settings and process management for testing
136+ - ** UpdateManager** : App updates via Sparkle framework (offline by default)
137+ - ** WindowHelper** : Detects window information under the cursor
110138
111139### Test Layer
112- - ** GestureModelsTests ** : Unit tests for gesture state and configuration
113- - ** GestureRecognizerTests ** : Unit tests for gesture recognition logic including palm rejection
114- - ** TouchModelsTests ** : Unit tests for touch data structures
140+ - Comprehensive unit tests for all components
141+ - Mock objects for isolated testing
142+ - Tests for gesture recognition, touch models, and UI components
115143
116144## Design Patterns Used
117145
@@ -120,6 +148,7 @@ Root Files:
1201483 . ** Observer Pattern** : Using NotificationCenter for preferences
1211494 . ** Factory Pattern** : Device creation in MultitouchFramework
1221505 . ** Strategy Pattern** : Configurable gesture recognition
151+ 6 . ** Protocol-Oriented Design** : For dependency injection and testability
123152
124153## Adding New Features
125154
@@ -131,11 +160,13 @@ To add a new feature, identify which layer it belongs to:
1311604 . ** New menu item?** → Add to MenuBarController
1321615 . ** New device support?** → Extend DeviceMonitor
1331626 . ** New test?** → Add to MiddleDragTests target
163+ 7 . ** Accessibility feature?** → Update AccessibilityMonitor
164+ 8 . ** Multi-monitor handling?** → Update ScreenHelper
134165
135166## Dependencies
136167
137168The refactored code maintains minimal dependencies:
138- - No external Swift packages required
169+ - No external Swift packages required (except Sparkle for updates and Sentry for analytics/error reporting)
139170- Uses only system frameworks
140171- Private framework access isolated to one file
141172
0 commit comments