DEV Community

Karan Kunal Mohindroo
Karan Kunal Mohindroo

Posted on

MiddleDrag: Middle-click for Mac trackpads, built with Copilot CLI

GitHub Copilot CLI Challenge Submission

This is a submission for the GitHub Copilot CLI Challenge

What I Built

MiddleDrag is a free, open-source macOS menu bar app that adds middle-click and middle-drag to trackpads via three-finger gestures.

Mac trackpads don't have a middle button, which is painful for 3D/CAD work (Blender, SketchUp, Fusion 360), browser power users (open/close tabs), and developers (IDE scroll-click). Existing solutions are either paid, abandoned, or require disabling Mission Control.

MiddleDrag works alongside system gestures: it backs off when you use four fingers, so Mission Control still works.

Website: https://middledrag.app
GitHub: https://github.com/NullPointerDepressiveDisorder/MiddleDrag**

brew tap nullpointerdepressivedisorder/tap && brew install --cask middledrag
Enter fullscreen mode Exit fullscreen mode

UI (Demo Available on both Website and Repo)

MiddleDrag UI

My Experience with GitHub Copilot CLI

Building MiddleDrag meant working with Apple's private MultitouchSupport framework — there's no official documentation, no WWDC sessions, just scattered blog posts and reverse-engineered headers. Copilot CLI became my research partner.

Debugging race conditions

The hardest bug was a race condition in the stuck drag prevention system. MiddleDrag monitors touch state across multiple dispatch queues, and occasionally the mouse button would get "stuck" down. I'd describe the symptoms:

gh copilot explain "why would a DispatchWorkItem.cancel() not prevent execution if called immediately before the deadline"
Enter fullscreen mode Exit fullscreen mode

Copilot walked me through the timing edge cases with GCD and suggested using a cancellation flag pattern instead of relying solely on cancel(). That pointed me toward the fix.

Understanding private APIs

When I needed to figure out the callback signature for MTRegisterContactFrameCallback, I couldn't just check Apple's docs. I'd ask:

gh copilot explain "what does MTRegisterContactFrameCallback expect as parameters based on MultitouchSupport.h"
Enter fullscreen mode Exit fullscreen mode

It synthesized information from the reverse-engineered headers and community posts, giving me a working starting point instead of hours of trial and error.

Git archaeology

MiddleDrag has gone through several refactors. When I needed to understand why a particular approach was chosen:

gh copilot suggest "find commits that changed GestureRecognizer.swift related to cooldown"
Enter fullscreen mode Exit fullscreen mode

It generated the right git log incantation with -p, --grep, and path filters: commands I'd have to look up every time otherwise.

Shell commands I'll never memorize

Code signing and notarization for macOS distribution involves arcane codesign and xcrun notarytool flags. Instead of digging through man pages:

gh copilot suggest "verify app signature and notarization status for MiddleDrag.app"
Enter fullscreen mode Exit fullscreen mode

It gave me the exact sequence: codesign --verify --deep --strict, spctl --assess --type exec, and xcrun stapler validate. I ran these constantly during release testing.

Documentation consistency

Writing the README and inline documentation, I'd draft a section and ask:

gh copilot explain "rewrite this to match the tone of the rest of the README"
Enter fullscreen mode Exit fullscreen mode

It kept the docs consistent, concise, technically accurate, and scannable. The README has been one of the most-praised parts of the project.


The pattern that emerged: Copilot CLI is most valuable when you almost know what you need but the exact syntax, flag, or API detail would take 15 minutes to look up. For a project touching private frameworks, code signing, and Swift concurrency, that happened constantly.

Top comments (0)