Skip to content

Add a touchscreen right click and a seam for the release-bypass tests - #41

Merged
thirteen37 merged 1 commit into
mainfrom
feature/touchscreen-right-click-and-viewmodel-seam
Aug 21, 2026
Merged

thirteen37 merged 1 commit into
mainfrom
feature/touchscreen-right-click-and-viewmodel-seam

Conversation

@thirteen37

Copy link
Copy Markdown
Owner

Closes the two loose ends left after #40.

Two-finger tap → right click

Restricting the secondary tap recognizer to .indirectPointer in #40 fixed taps arriving as right clicks, but left no way to right-click at all without a trackpad or mouse attached. A two-finger tap now fills that gap, routed through the existing emitClick(buttonNumber: 1, …) so it inherits the same 50 ms hold.

It's restricted to .direct touches deliberately: a trackpad's two-finger tap already arrives as an indirect secondary click, so without the restriction both recognizers would fire for one gesture.

Checked for conflicts — a stationary two-finger tap starts neither the pan (needs movement past slop) nor the pinch (needs a scale change), so wheel scrolling and zoom are unaffected.

Long-press was the alternative convention. It collides with the one-finger drag, which handlePan already treats as a held left button, so pausing before a drag would fire a spurious right click first.

ViewerViewModel test seam

sendInputRelease bypasses the capture guard on purpose — a button or key held when capture is switched off would otherwise stay pressed on the host forever. That was only verified by reading it, because the session was built internally with no way to substitute one.

init now takes a defaulted session: parameter, so every existing call site is unchanged, and MockKVMSession records what reaches the session.

Verification

Both new behaviours were checked against a deliberately broken version, not just a green run. Adding guard isMouseCaptureEnabled back onto the bypass fails the test with:

XCTAssertEqual failed: ("0") is not equal to ("1")

Test plan

  • KVMCore 171/171 (+4 view-model tests)
  • iPadOS 20/20 (+1 two-finger tap test)
  • macOS suite passes
  • Release-bypass test verified to fail when the bypass is guarded
  • Hardware: two-finger tap produces a right click on the host
  • Hardware: one-finger tap still produces a left click, and two-finger scroll still scrolls
  • Hardware: trackpad right click produces exactly one right click, not two

🤖 Generated with Claude Code

Restricting the secondary tap recognizer to indirect pointer input left no way
to right-click without a trackpad or mouse attached. A two-finger tap fills
that gap, routed through the same click path so it gets the same hold. It is
restricted to direct touches because a trackpad's two-finger tap already
arrives as an indirect secondary click, and both firing would double up. A
stationary two-finger tap starts neither the pan nor the pinch, so wheel
scrolling and zoom are unaffected.

Long-press was the alternative but collides with the one-finger drag, which is
already a held left button: pausing before a drag would fire a spurious right
click first.

ViewerViewModel's session is now injectable, so sendInputRelease's deliberate
bypass of the capture guard is covered by tests rather than by reading it. The
parameter is defaulted, so every existing call site is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XU7Ck7AbZ9KpRhdPbRzNj8
@thirteen37
thirteen37 merged commit d9561ce into main Aug 21, 2026
3 checks passed
@thirteen37
thirteen37 deleted the feature/touchscreen-right-click-and-viewmodel-seam branch August 21, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant