Skip to content

fix: let the webcam preview bubble cross monitor boundaries while dragging - #7

Open
Alfredoalv13 wants to merge 1 commit into
mainfrom
fix/webcam-preview-multi-monitor-drag
Open

fix: let the webcam preview bubble cross monitor boundaries while dragging#7
Alfredoalv13 wants to merge 1 commit into
mainfrom
fix/webcam-preview-multi-monitor-drag

Conversation

@Alfredoalv13

Copy link
Copy Markdown
Owner

Summary

  • The floating camera preview bubble had the same single-display limitation the HUD control bar had before fix: let the HUD widget cross monitor boundaries while dragging #4 — drag math clamped to window.innerWidth/innerHeight (one display's work area), so it could never be dragged onto a second monitor.
  • Applies the same fix pattern as fix: let the HUD widget cross monitor boundaries while dragging #4: track a fixed grab offset (distance from the bubble's edge to the click point) instead of a client-coordinate delta snapshot, compute the target position in absolute screen coordinates (event.screenX/screenY minus window.screenX/screenY) so it stays correct even if the HUD window relocates mid-drag, and re-measure the bubble's actual rendered rect every frame so any mid-drag window resize is absorbed automatically instead of causing a jump.
  • Reuses the existing hudOverlayRelocateToPoint IPC call — the webcam bubble renders inside the same HUD overlay window as the control bar, so no main-process changes are needed here.

Why

Confirmed by reading the code: PR #4 only touched useHudBarDrag.ts (the control bar). This hook (useWebcamPreviewOverlay.ts) has its own, separate drag implementation with the identical bug and no relocate mechanism at all.

Test plan

  • npx tsc — clean
  • npx vitest --run — 786/786 passing
  • npx biome check on the changed file — clean (one pre-existing, unrelated formatting issue on main left untouched)
  • Manual: drag the floating webcam preview bubble from the laptop screen onto a second monitor, confirm it crosses cleanly with no jump

…gging

The floating camera preview bubble had the same single-display limitation
the HUD control bar had before #4: its drag math clamped to
window.innerWidth/innerHeight (one display's work area) with no way to
hop onto a second monitor.

Applies the same fix as #4 - track a fixed grab offset instead of a
client-coordinate snapshot, compute the target position in absolute
screen coordinates so it stays correct if the HUD window relocates
mid-drag, and re-measure the bubble's actual rendered rect every frame
so a mid-drag window resize is absorbed automatically. Reuses the
existing hudOverlayRelocateToPoint IPC call (same window as the HUD bar)
with no main-process changes needed.
@Alfredoalv13

Copy link
Copy Markdown
Owner Author

Internal bug-hunter review

Reviewed against the reference implementation (useHudBarDrag.ts, merged in #4) with focus on what's different in this port: the drag-threshold gating, the unconditional pointerUp recompute, external consumers of the ref's shape, and the two independent relocate in-flight guards.

No confirmed bugs. Summary:

  • Screen-coordinate threshold check is sound (actually more robust than the old client-coordinate diff, since it's immune to spurious deltas from external window movement).
  • The unconditional pointerUp position recompute (matching the HUD bar's pattern) can nudge the bubble by at most the 6px drag threshold on a plain click — negligible, and nothing reads the bubble's exact position from a click handler.
  • Confirmed via grep: nothing outside this hook depends on the old drag-state ref shape (startX/initialLeft/etc.) — only truthiness is read externally.
  • The two hooks' independent relocate in-flight guards are safe: the main-process handler is stateless and idempotent per call, so there's no read-modify-write race between them.

One pre-existing, out-of-scope note: the unmount cleanup effect doesn't null webcamPreviewDragStartRef.current (unlike the reference's cleanup, which does null its equivalent) — but that line wasn't touched by this diff, so it's not this PR's concern.

Ready for your manual verification (drag the bubble across a real second monitor) before merge.

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.

2 participants