Skip to main content

Module overlay

Module overlay 

Source

Functions§

abort_stranded_break 🔒
Tear down a break whose overlay never reported rendering — the #196/#226 watchdog firing, or the shown == 0 no-overlay case. Mirrors the cleanup half of end_break (clear the current break, resume any paused media, hide every overlay window, emit break:end) but records no stats: an invisible break was never taken or dismissed. Scheduler-free so the watchdog task can run it from cloned Arcs without holding &Scheduler.
active_indices 🔒
Monitor index to cover for the Active placement: whichever monitor holds the cursor, else the reported primary, else the first available. Pure so the fallback chain is unit-testable. Returns an empty list only when there are no monitors at all.
centered_windowed_rect
Shrink monitor to fraction of its size and centre it inside the original. fraction is clamped to [0.1, 1.0]. Used to size the BreakDelivery::Windowed overlay so the desktop stays clickable around it.
deliver_break
Surface a break through whichever channel the active settings ask for: a system notification or the overlay (full-screen or windowed). Notification delivery short-circuits the overlay path entirely.
ensure_overlay 🔒
fire_break
Stash the break event in current_break, position an overlay window on each selected monitor, and emit break:start to the renderer. Used directly for sleep/resume-last paths; normal scheduled breaks go through deliver_break instead.
format_break_duration
Human-friendly break duration for notifications (e.g. "20 seconds", "5 minutes", "1m 30s"). Drops the seconds part when the duration is a whole-minute multiple.
hide_overlay_windows 🔒
Hide every break overlay window. Shared by the break-teardown paths (end_break, postpone_break, and the render watchdog) so the "overlay-" label convention lives in exactly one place.
is_wayland_session 🔒
Whether this is a Wayland session. Used to decide if the overlay geometry needs the HiDPI scale correction below (#67). Mirrors the probe in video.rs; kept local so the overlay path stays self-contained.
monitor_index_by_rect 🔒
Locate needle in rects by identity-ish geometry match on position and size. available_monitors and primary_monitor return independent Monitor values, so the only stable cross-reference is their reported rect. Pure so the lookup is unit-testable.
monitor_rect 🔒
notify_break_now 🔒
pick_active_monitor
Index of the monitor that contains (cursor_x, cursor_y), or None if the cursor sits outside every rect. Used by MonitorPlacement::Active to decide which display the overlay should pop on.
post_notification 🔒
Post a desktop notification. Split on cfg(test) so the OS-posting body is compiled out of the test/coverage build: the scheduler’s delivery tests drive the routing glue end to end, and without this a real tauri_plugin_notification would post an actual macOS notification on every cargo test run — attributed to the terminal, since a test binary is not an app bundle. The routing the tests assert runs before this call, so no meaningful coverage is lost.
primary_or_all_indices 🔒
Monitor indices to cover for the Primary placement. When the windowing system names a primary monitor we cover exactly it. When it can’t (Wayland has no “primary” concept) we cover every monitor instead of just the first: “the primary screen” is meaningless there, and leaving the other monitors uncovered lets the user dodge an enforceable break by glancing at the next screen (#67, Steffi’s dual-monitor setup). Pure so the fallback is unit-testable without a windowing system.
read_display_geometry 🔒
Read the display layout on the main thread and hand back plain data.
resolve_overlay_indices 🔒
Resolve a placement to the set of monitor indices that should each get an overlay window, given what the windowing system could report.
scale_corrected_rect 🔒
Correct a monitor’s reported geometry for the GNOME/Wayland HiDPI quirk where tao returns monitor.size() and position() already multiplied by the scale factor. Feeding those straight into set_size/set_position (which divide by the window’s scale factor again) builds an overlay scale× too large in each axis — it spills onto the neighbouring monitor and pushes the hint and Skip controls off the bottom of the screen (#67, Steffi’s 2×4K @ 200% report). On Wayland with a >1 scale we divide back out to the true physical geometry; on X11 and macOS monitor.size() is already true physical, so it’s a no-op. Pure so the correction is unit-testable without a windowing system.
select_overlay_monitors 🔒
spawn_render_watchdog 🔒
Spawn the grace-period task that aborts a never-rendered break. Captures cloned Arcs + AppHandle so it outlives fire_break’s borrows.
wayland_session_from_env 🔒
Pure Wayland-session test over the two relevant env signals, split out so the decision is unit-testable without mutating process env.