Skip to main content

Module blur

Module blur 

Source
Expand description

Blur-dismiss state and generic window-lifecycle event helpers.

A launcher-style window commonly wants two behaviors: hide (rather than quit) when the user clicks the close button, and optionally hide when it loses focus (“click away to dismiss”). This module owns the runtime gate and decision logic; the app wires it into on_window_event.

Structs§

BlurDismissState
Runtime gate for blur-dismiss, toggled at runtime (e.g. while a result or settings view is open, the app may want to suppress hide-on-blur so resizing or copying from another window doesn’t make it vanish).

Functions§

handle_close_requested
WindowEvent::CloseRequested handler: prevent the actual close and hide the window instead, so the app keeps running in the tray.
handle_focus_lost
WindowEvent::Focused(false) handler: hide window when should_hide_on_blur allows it. hide_on_blur_pref is the caller’s product-owned settings value (not this crate’s concern).
handle_focus_lost_from_managed_state
Convenience: fetch state’s BlurDismissState from window’s AppHandle and call handle_focus_lost. Requires state to have been registered via app.manage(BlurDismissState::default()) (or similar).
should_hide_on_blur
Decide whether a focus-lost event should hide the window: both the runtime gate (blur_dismiss_enabled, from BlurDismissState::enabled) and the user’s persisted preference (hide_on_blur_pref, product-owned settings) must allow it.