Expand description
M-BUBBLE.3 / AUT-276 — webcam-bubble position math + corner snap.
Pure-Rust helpers: no Tauri, no I/O, no async. The Tauri-side
caller in commands.rs invokes default_position when the
bubble first opens without a saved position, is_on_any_monitor
to validate a restored position is still visible after a display
unplug, and snap_to_nearest_corner for the snap-on-drag UX
(wired in a follow-up — for v0 these helpers ship tested but the
Moved event wiring stays inert to avoid the set-position →
Moved → set-position loop without a debounce in place).
Structs§
- Bubble
Position - On-disk-serialisable bubble window position. Stored as logical
pixels (the units
tauri::WebviewWindow::set_positionaccepts).
Enums§
- Corner
- Which corner of a monitor a window is closest to. Returned by
snap_to_nearest_corner(viaOption<(i32, i32, Corner)>) so the caller can render a “snapped to top-right” visual hint distinct from “free-floating.”
Functions§
- default_
position - Default first-open position: bottom-LEFT of the supplied monitor,
inset by
inset_pxfrom both edges so the bubble doesn’t kiss the dock / taskbar. Matches the Screenplay-style design reference where the webcam bubble lives in the bottom-left corner of the screen by default (the user can drag it anywhere; the new position is persisted viabubble-position.txt). - is_
on_ any_ monitor trueiff the bubble (top-left atpos, size(w, h)) is at least partially visible on any of the supplied monitors. Used after a display unplug to decide whether the persisted position is still usable or should fall back todefault_position.- snap_
to_ nearest_ corner - If the bubble’s top-left is within
snap_radius_pxof any monitor’s nearest corner (measured corner-to-corner of the window vs monitor), snap to that corner’s exact position and return the snapped(BubblePosition, Corner). OtherwiseNone.
Type Aliases§
- Corner
Candidate 🔒 - Internal helper type — pairs a corner identity with the screen
coordinates of two matching points (the window’s corner and the
monitor’s corner) used to compute the Manhattan distance between
them. Aliased so the array literal stays readable + clippy’s
type_complexitylint is satisfied.