pub struct IdleOptions {
pub suspend_after: Duration,
pub start_on_minimize: bool,
pub controller_hide: ControllerHide,
pub events: IdleEvents,
pub trigger: IdleTrigger,
/* private fields */
}Expand description
Per-host idle options (see crate::ShellBuilder::webview_idle_options). The default is the
behaviour webview_idle(DEFAULT_SUSPEND_AFTER) has always had.
Not Copy: it may hold a delay provider (see IdleOptions::suspend_after_with). It cannot be
built with a struct literal outside this crate, not even with ..IdleOptions::default(),
because the provider field is private. Build it with the setters:
IdleOptions::default().suspend_after(d).start_on_minimize(true).
Fields§
§suspend_after: DurationHidden this long before the webview is suspended (clamped to MAX_SUSPEND_AFTER). With a
provider set, this is the value used whenever the provider returns None or fails.
start_on_minimize: boolAlso start the idle timer when the main window is minimised, not only on a hide the shell or
host reports (note_hidden). Restoring the window ends it. Default off.
controller_hide: ControllerHide§events: IdleEvents§trigger: IdleTriggerWhat starts idle; IdleTrigger::Minimised makes it minimise-only.
Implementations§
Source§impl IdleOptions
impl IdleOptions
Sourcepub fn suspend_after(self, suspend_after: Duration) -> Self
pub fn suspend_after(self, suspend_after: Duration) -> Self
Set the fixed suspend delay (see the field of the same name).
Sourcepub fn start_on_minimize(self, start_on_minimize: bool) -> Self
pub fn start_on_minimize(self, start_on_minimize: bool) -> Self
Also start the idle timer when the main window is minimised.
Sourcepub fn controller_hide(self, controller_hide: ControllerHide) -> Self
pub fn controller_hide(self, controller_hide: ControllerHide) -> Self
Choose when the controller is hidden.
Sourcepub fn trigger(self, trigger: IdleTrigger) -> Self
pub fn trigger(self, trigger: IdleTrigger) -> Self
Choose what starts idle (see IdleTrigger).
Sourcepub fn on_minimise(self, on_minimise: bool) -> Self
pub fn on_minimise(self, on_minimise: bool) -> Self
Minimise-only idle: true is trigger(IdleTrigger::Minimised) (a minimise starts idle, a
tray hide does not), false restores the default trigger.
Sourcepub fn minimise_enabled(&self) -> bool
pub fn minimise_enabled(&self) -> bool
Whether a minimise of the main window feeds the idle machine.
Sourcepub fn events(self, events: IdleEvents) -> Self
pub fn events(self, events: IdleEvents) -> Self
Choose which idle events are emitted.
Sourcepub fn suspend_after_with(
self,
provider: impl Fn() -> Option<Duration> + Send + Sync + 'static,
) -> Self
pub fn suspend_after_with( self, provider: impl Fn() -> Option<Duration> + Send + Sync + 'static, ) -> Self
Read the suspend delay at each hide instead of fixing it at build time.
provider is called once per hide transition (a window hide, or the start of a minimise
when start_on_minimize is set), never at build time. Its Some(d) is the delay for that
hide, clamped to MAX_SUSPEND_AFTER; None uses the fixed suspend_after. A panic in
provider is caught and also uses the fixed suspend_after. An explicit per-hide delay
(note_hidden_after, note_minimized_after, rk_shell_idle_note) takes precedence and the
provider is not called for that hide.
Takes self, so it chains onto the default and the other setters:
IdleOptions::default().suspend_after_with(|| Some(read_env())).
Sourcepub fn hide_delay(
&self,
host_default: Duration,
per_hide: Option<Duration>,
) -> Duration
pub fn hide_delay( &self, host_default: Duration, per_hide: Option<Duration>, ) -> Duration
The suspend delay for one hide, evaluating the provider now (once per call). Precedence:
per_hide if given, else the provider’s Some, else host_default (the fixed
suspend_after). The result is clamped to MAX_SUSPEND_AFTER.
Trait Implementations§
Source§impl Clone for IdleOptions
impl Clone for IdleOptions
Source§impl Debug for IdleOptions
impl Debug for IdleOptions
Source§impl Default for IdleOptions
impl Default for IdleOptions
impl Eq for IdleOptions
Source§impl PartialEq for IdleOptions
impl PartialEq for IdleOptions
impl StructuralPartialEq for IdleOptions
Auto Trait Implementations§
impl !RefUnwindSafe for IdleOptions
impl !UnwindSafe for IdleOptions
impl Freeze for IdleOptions
impl Send for IdleOptions
impl Sync for IdleOptions
impl Unpin for IdleOptions
impl UnsafeUnpin for IdleOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.