MiddleDrag

repository·main·Indexed 42 days ago

https://github.com/nullpointerdepressivedisorder/middledrag

A macOS utility that enables middle-click and middle-drag functionality using three-finger trackpad gestures. Designed for users needing middle-mouse input in browsers, design tools, 3D software, and IDEs without a physical mouse.

Tokens
1.4K
Snippets
4
Records
10
Agent score
4%

What's inside MiddleDrag

  1. Understand the MiddleDrag architecture and layers

    main

    MiddleDrag uses a modular, layered architecture designed for separation of concerns and testability. The project is organized into five primary functional layers:

    • Core Layer: Handles low-level interactions, including private Apple framework bindings (MultitouchFramework), gesture detection (GestureRecognizer), mouse event synthesis (MouseEventGenerator), and device monitoring protocols (TouchDeviceProviding).
    • Model Layer: Contains pure data structures for touch data (TouchModels) and gesture state/configuration (GestureModels).
    • Manager Layer: Contains the business logic and coordination. Key components include the MultitouchManager (main coordinator), DeviceMonitor (lifecycle/callbacks), and AccessibilityMonitor (permission polling).
    • UI Layer: Manages user-facing elements like the MenuBarController and AlertHelper.
    • Utility Layer: Provides cross-cutting services such as PreferencesManager (persistence), ScreenHelper (multi-monitor coordinate conversion), UpdateManager (Sparkle-based updates), and LaunchAtLoginManager.
  2. MiddleDrag design patterns

    main

    The project follows several key architectural patterns to maintain loose coupling and testability:

    • Protocol-Oriented Design: Used extensively for dependency injection (e.g., TouchDeviceProviding).
    • Delegate Pattern: Used for loose coupling between components.
    • Observer Pattern: Utilizes NotificationCenter for handling preference changes.
    • Singleton Pattern: Used for shared managers where appropriate.
    • Factory Pattern: Used for device creation within MultitouchFramework.
    • Strategy Pattern: Used for configurable gesture recognition logic.
  3. How to add new features to MiddleDrag

    main

    When extending MiddleDrag, determine the appropriate layer for your changes based on the following mapping:

    Feature TypeTarget Component
    New gesture typeGestureRecognizer
    New mouse actionMouseEventGenerator
    New preferencePreferencesManager and GestureModels
    New menu itemMenuBarController
    New device supportDeviceMonitor
    New accessibility featureAccessibilityMonitor
    Multi-monitor handlingScreenHelper
    New unit testAdd to MiddleDragTests target
  4. Install MiddleDrag manually

    main

    To install without a package manager:

    1. Download the latest .pkg installer from the Releases page.
    2. Open the installer and follow the prompts.
    3. Launch MiddleDrag from your Applications folder.
    4. Important: Grant Accessibility permissions when prompted by macOS.

    Verify Download Integrity

    If you have the GitHub CLI installed, you can verify the cryptographic attestation of the downloaded package:

    # Requires GitHub CLI: brew install gh
    gh attestation verify ~/Downloads/MiddleDrag-{VERSION}.pkg --repo NullPointerDepressiveDisorder/MiddleDrag
    gh attestation verify ~/Downloads/MiddleDrag-{VERSION}.pkg --repo NullPointerDepressiveDisorder/MiddleDrag
  5. Use three-finger gestures for middle-click and middle-drag

    main

    MiddleDrag runs as a native macOS app in your menu bar (represented by a hand icon). It maps trackpad gestures to middle-mouse actions:

    GestureAction
    Three-finger tapMiddle click
    Three-finger dragMiddle drag (pan/orbit)

    This is useful for:

    • Browsers: Opening links in new background tabs or closing tabs.
    • Design Tools (Figma, Photoshop): Panning the canvas.
    • 3D Software (Blender, Maya): Orbiting and panning viewports.
    • Development: Closing editor tabs in VS Code or Sublime Text.
  6. Configure MiddleDrag settings

    main

    Access settings via the MiddleDrag menu bar icon. Available configurations include:

    • Enabled: Toggle gesture recognition on or off.
    • Drag Sensitivity: Adjust the cursor speed during a middle-drag (range: 0.5x to 2x).
    • Require Exactly 3 Fingers: When enabled, the app will ignore touches involving 4 or more fingers.
    • Launch at Login: Automatically start MiddleDrag when macOS boots.
  7. Troubleshoot MiddleDrag gestures

    main

    If gestures are not working, follow these steps:

    Gestures not working

    1. Check Accessibility permissions: Go to System Settings → Privacy & Security → Accessibility and ensure MiddleDrag is enabled.
    2. Toggle "Enabled" in the MiddleDrag menu bar.
    3. Restart the app.

    Gestures stopped working after an update

    macOS treats each app version as a new application and may revoke permissions. To fix this:

    1. Go to System Settings → Privacy & Security → Accessibility.
    2. Toggle MiddleDrag off then on.
    3. Restart MiddleDrag.

    Conflicts with system gestures

    While designed to coexist with Mission Control and Exposé, pressing down hard on the trackpad may still trigger system gestures. Using "soft taps" instead of physical clicks can help avoid conflicts.