Skip to content

feat(web): add a trackpad mode for touch screens - #115

Merged
DarrenBaldwin07 merged 1 commit into
mainfrom
tembo/trackpad-mode
Nov 19, 2026
Merged

DarrenBaldwin07 merged 1 commit into
mainfrom
tembo/trackpad-mode

Conversation

@DarrenBaldwin07

Copy link
Copy Markdown
Contributor

What

Adds a trackpad mode for phones and tablets. In the default touch mode, the desktop pointer jumps to wherever the finger lands. In trackpad mode the screen works like a laptop trackpad: the finger moves a cursor relative to where it is, and clicks land on the cursor, not under the finger. That makes small targets usable on a phone, where a fingertip covers several desktop pixels.

A new toolbar button switches between the two modes. It only appears on touch devices and is hidden for read-only viewers. The browser remembers the choice in localStorage.

Left: trackpad mode on (390×844 phone, 1600×1000 desktop), with the button highlighted and the desktop's cursor drawn at the pointer. Right: pinched in to 4.4×, where the cursor keeps its normal size.

trackpad mode

Gestures (trackpad mode)

  • One finger: moves the cursor from where it is. A slow move covers the same distance on the screen as the finger. Faster moves go farther, up to 3× (1 + 0.8 × speed in CSS px/ms).
  • Tap: clicks where the cursor is. The cursor doesn't move between taps, so a double tap double-clicks.
  • Two-finger tap: right clicks where the cursor is. Both fingers must lift within 300 ms of the second one landing, without moving.
  • Press and hold, then move: drags. After 550 ms the button goes down where the cursor is (with a vibration), and lifting the finger releases it.
  • Two fingers / pinch: same as touch mode. Two fingers scroll (or pan a zoomed-in view), and pinching zooms.
  • The whole screen is the trackpad, including the black bands around a desktop letterboxed on a phone.
  • When zoomed in, the view follows the cursor and keeps it 32 px inside the window.

Touch mode, mouse, and pen input are unchanged.

How

  • touch.ts: trackpad mode is a flag on the existing gesture state machine, so the two-finger scroll/pinch logic is shared. It adds a move state (relative cursor movement) and changes what tap, long press, and a two-finger tap do.
  • pointer.ts: keeps the pointer's desktop position, using fractions while gliding so slow moves don't lose precision. Adds moveBy (relative move, plus the zoomed view following the cursor) and setTrackpad. A new #pad element behind the desktop covers the window in trackpad mode. A touch that lands on it captures the pointer to the surface, so the rest of the gesture goes through the usual handlers.
  • cursor.ts: touch screens show no CSS cursor, so the cursor image the server sends is also drawn on #pointer, positioned in percent of the surface. #pointer is hidden when the desktop hides its cursor. It also stays hidden when the server sends no cursor images, as with macOS --show-cursor, where the cursor is already in the video.
  • zoom.ts: sets --zoom on the surface, and #pointer scales back by 1 / --zoom around its hotspot to keep its size.
  • toolbar.ts / index.html: the toggle button (shown on touch devices, hidden when read-only), its persistence, and the styles.
  • README: describes trackpad mode under the touch FAQ.

Testing

  • npm run check (oxfmt, oxlint, tsc) passes.
  • Built voxl and streamed a 1600×1000 Xvfb desktop to headless Chromium emulating a phone (390×844 @3x, isMobile, hasTouch). I drove multi-touch with CDP Input.dispatchTouchEvent against a page on the desktop that records the pointer position, clicks, double-clicks, context menus, and a draggable box:
    • Toggle: the button showed aria-pressed="true", the cursor appeared, and the mode survived a reload.
    • Slow 30 px swipe in the black band below the desktop: the cursor moved 123 desktop px (1:1 on screen) with no click. A fast 30 px swipe moved it 166 px.
    • Tap away from the cursor: one click, at the cursor (1053, 0) rather than under the finger.
    • Double tap: 2 clicks and 1 dblclick.
    • Two-finger tap: 1 contextmenu at the cursor. Two-finger swipe: no clicks or context menus.
    • Press and hold on the box, then move (-30, +30) CSS px: the box moved (-123, +122) desktop px.
    • Pinch to 4.4×: the cursor stayed 15×24 CSS px. Moving the cursor right panned the view to the desktop's right edge.
    • With trackpad mode off, a tap clicked under the finger as before.
  • Not tested on a physical iOS/Android device.

Want tembo to make any changes? Add a comment with @tembo and i'll get back to work!

View on Tembo  Review in Tembo  View Agent Settings  View on slack

@tembo tembo Bot added the tembo Pull request created by Tembo label Nov 19, 2026
@DarrenBaldwin07
DarrenBaldwin07 merged commit ee39e60 into main Nov 19, 2026
10 checks passed
DarrenBaldwin07 added a commit that referenced this pull request Nov 19, 2026
## What

Bumps voxl from 0.3.5 to 0.4.0 in `Cargo.toml`, `Cargo.lock` and
`default.nix`. Once this merges, pushing the `v0.4.0` tag on the merge
commit publishes the crate to crates.io and creates the GitHub release,
with generated notes and the crate attached (`release.yml`).

Changes since the `v0.3.5` tag:

- perf: build x264 with patches that skip unchanged macroblocks (#116)
- feat(web): add a trackpad mode for touch screens (#115)
- build: declare rust-version 1.86, the Rust the Linux CI job builds
with (#107)

The `v0.3.5` tag points at #99 (the optional `pulseaudio` feature), so
that change is already in 0.3.5 and isn't repeated here.

## Testing

- `cargo metadata --locked` passes, so `Cargo.lock` matches
`Cargo.toml`.
 
  


 <br /> 


> Want tembo to make any changes? Add a comment with `@tembo` and i'll
get back to work!


<a
href="https://app.tembo.io/sessions/75ad8969-8072-458a-973b-b4f3cec3bbac"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://internal.tembo.io/static/view/tembo-dark.png?v=3"><source
media="(prefers-color-scheme: light)"
srcset="https://internal.tembo.io/static/view/tembo-light.png?v=3"><img
alt="View on Tembo"
src="https://internal.tembo.io/static/view/tembo-light.png?v=3"
width="134" height="28"></picture></a>&nbsp;&nbsp;<a
href="https://app.tembo.io/reviews/redirect?sessionId=75ad8969-8072-458a-973b-b4f3cec3bbac"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://internal.tembo.io/public/tembo-button/review?theme=dark&v=3"><source
media="(prefers-color-scheme: light)"
srcset="https://internal.tembo.io/public/tembo-button/review?theme=light&v=3"><img
alt="Review in Tembo"
src="https://internal.tembo.io/public/tembo-button/review?theme=light&v=3"
width="145" height="28"></picture></a>&nbsp;&nbsp;<a
href="https://app.tembo.io/settings/models"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://internal.tembo.io/public/agent-button/claudeCode:claude-opus-5-5:xhigh?theme=dark&v=12"><source
media="(prefers-color-scheme: light)"
srcset="https://internal.tembo.io/public/agent-button/claudeCode:claude-opus-5-5:xhigh?theme=light&v=12"><img
alt="View Agent Settings"
src="https://internal.tembo.io/public/agent-button/claudeCode:claude-opus-5-5:xhigh?theme=light&v=12"
height="28"></picture></a>&nbsp;&nbsp;<a
href="https://tembo-io.slack.com/archives/C08S9PXF1KJ/p1795122498696389"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://internal.tembo.io/public/vendor-button/slack?theme=dark&v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://internal.tembo.io/public/vendor-button/slack?theme=light&v=2"><img
alt="View on slack"
src="https://internal.tembo.io/public/vendor-button/slack?theme=light&v=2"
height="28"></picture></a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tembo Pull request created by Tembo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant