Skip to main content

Module bubble_position

Module bubble_position 

Source
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§

BubblePosition
On-disk-serialisable bubble window position. Stored as logical pixels (the units tauri::WebviewWindow::set_position accepts).

Enums§

Corner
Which corner of a monitor a window is closest to. Returned by snap_to_nearest_corner (via Option<(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_px from 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 via bubble-position.txt).
is_on_any_monitor
true iff the bubble (top-left at pos, 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 to default_position.
snap_to_nearest_corner
If the bubble’s top-left is within snap_radius_px of 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). Otherwise None.

Type Aliases§

CornerCandidate 🔒
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_complexity lint is satisfied.