feat(mac): Pen / Draw Mode — single pointer draws instead of scrolling - #51
Draft
crsxmd wants to merge 2 commits into
Draft
feat(mac): Pen / Draw Mode — single pointer draws instead of scrolling#51crsxmd wants to merge 2 commits into
crsxmd wants to merge 2 commits into
Conversation
The gesture state machine treats a single pointer as a trackpad: a stroke that moves more than tapMaxDistance before longPressTime elapses becomes a scroll, so drawing with a stylus pans the canvas instead of leaving a line. Pen / Draw Mode routes a single pointer straight onto the left button — down presses immediately, move drags, up releases — so a stroke draws. Two pointers are dispatched before the mode is consulted, leaving two-finger scroll and pinch untouched for panning and zooming. Off by default. Also releases a held left button on every path where a stroke can end without its touch-up: client disconnect, stopServer, touch input turned off, and a second finger landing mid-stroke. That could already strand the button down with long-press dragging; pen mode makes a held button the normal state of every stroke, so it would happen constantly. Direct-pointer input only — the touch protocol carries no pressure or tilt, so this does not close out the planned stylus support. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Someone is attempting to deploy a commit to the tranvuongquocdat2-7001's projects Team on Vercel. A member of the Team first needs to authorize it. |
A press has to declare its click count when it is posted, and pen mode presses on contact, so it cannot decide on release the way the trackpad path does. penDown now compares the contact against the previous tap using the existing doubleTapMaxTime/doubleTapMaxDistance thresholds and posts click 2 when it lands inside both; penUp releases with the same count. Only a contact that stays within tapMaxDistance for less than tapMaxTime can anchor the next double tap, so a drawn stroke ending near an earlier tap cannot chain into one. Without this, tapping twice sent two independent clicks and opening a file in Finder or expanding a window was impossible with the mode on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Summary
Adds Pen / Draw Mode, a Touch Control toggle that routes a single pointer straight onto the left mouse button so a stylus draws instead of scrolling.
Closes #45.
The gesture state machine currently treats one pointer as a trackpad: a stroke that travels further than
tapMaxDistancebeforelongPressTimeelapses becomes a scroll, so drawing pans the canvas. Waiting out the 500 ms long press before every stroke is the only way to get a line today, which is unusable for drawing.With the toggle on, and for a single pointer only:
leftMouseDownimmediately, no long-press waitleftMouseDraggedleftMouseUp(withmouseEventClickStateset, so a tap still reads as a complete click)Two pointers are dispatched before the mode is consulted, so two-finger scroll and pinch are untouched and panning/zooming a canvas still works.
Off by default. When the toggle is off the only changes on the existing path are one
Boolread and two branches that are unreachable unless the mode has been enabled, so every current gesture behaves exactly as before.This is direct-pointer input only. The touch payload carries
x, y, action, pointerCountand no pressure or tilt, so this deliberately does not close out the planned full stylus support — it is the small, Mac-only half of #45 that needs no wire-protocol or Android change.Relationship to open PRs
Also fixed
releaseHeldMouseButtonIfNeeded()posts the matchingleftMouseUpwhenever a stroke can end without its touch-up: client disconnect,stopServer(), touch input switched off, a second finger landing mid-stroke, and a fresh pen down that finds a previous stroke still open. Without it, pulling the USB cable mid-stroke leaves the left button physically down and every later cursor move drags across the Mac until a real mouse is clicked.It guards on
.penDrawing || .dragging, so it also covers the pre-existing long-press drag case (same ground as #46).Known limitations
MainActivityruns one-finger moves throughInputPredictor.predictPosition(12f)and reads onlyevent.x/yrather thangetHistorical*, so fast strokes can overshoot slightly at sharp corners. Left alone deliberately to keep this PR Mac-only.Testing
Verified:
swift buildclean, no warningsscripts/build_mac.shproduces the universal bundle; installed and launched on macOS 26.5.2, Apple Silicondefaults read com.sidescreen.app SideScreen_penModeEnabled)Not yet verified, which is why this is a draft:
Verified on hardware (Xiaomi Pad 6, USB, macOS 26.5.2):
Hardware here is a Xiaomi Pad 6 over USB. The reporter of #45 offered to test builds — happy to have this exercised on a Redmi Pad Pro before it is marked ready.
UI
The toggle sits under Touch Control directly below "Enable Touch Input", disabled when touch input is off, with a note listing what the mode turns off. Screenshot to follow before this leaves draft.