Skip to main content

IdleOptions

Struct IdleOptions 

Source
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: Duration

Hidden 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: bool

Also 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: IdleTrigger

What starts idle; IdleTrigger::Minimised makes it minimise-only.

Implementations§

Source§

impl IdleOptions

Source

pub fn suspend_after(self, suspend_after: Duration) -> Self

Set the fixed suspend delay (see the field of the same name).

Source

pub fn start_on_minimize(self, start_on_minimize: bool) -> Self

Also start the idle timer when the main window is minimised.

Source

pub fn controller_hide(self, controller_hide: ControllerHide) -> Self

Choose when the controller is hidden.

Source

pub fn trigger(self, trigger: IdleTrigger) -> Self

Choose what starts idle (see IdleTrigger).

Source

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.

Source

pub fn minimise_enabled(&self) -> bool

Whether a minimise of the main window feeds the idle machine.

Source

pub fn events(self, events: IdleEvents) -> Self

Choose which idle events are emitted.

Source

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())).

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IdleOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for IdleOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for IdleOptions

Source§

impl PartialEq for IdleOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for IdleOptions

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UserEvent for T
where T: Debug + Clone + Send + 'static,