Skip to main content

WindowHandle

Struct WindowHandle 

Source
pub struct WindowHandle { /* private fields */ }
Expand description

A live secondary window (docs/windows.md). Cheap to clone; inert after close.

Implementations§

Source§

impl WindowHandle

Source

pub fn set_content_scope(&self, scope: Scope)

Bind command/ambient lookup to retained document state without transferring scope ownership.

Source

pub fn on_close_request(&self, f: impl Fn() + 'static)

Route native user close requests to the document owner. close() still closes unconditionally after the owner has accepted and removed its content.

Source

pub fn on_focus(&self, f: impl Fn() + 'static)

Observe native activation (including selection of an OS window tab).

Source

pub fn tab_order(&self) -> Vec<NodeId>

Native order of this window’s tab group. Empty where unsupported.

Source

pub fn close(&self)

Close the window. Asynchronous: the platform (or the cover’s hide transition) confirms, then the content is disposed and on_close callbacks run. Focused-window lookup stops targeting this window as soon as close is requested. Idempotent.

Source

pub fn focus(&self)

Bring the window to front and make it key. No-op on the cover tier (the cover is already frontmost in the primary window) and while a Pending open is in flight.

Source

pub fn set_title(&self, title: &str)

Retitle the window. Applies to live native windows; a Pending window picks the new title up at completion; the cover tier has no title bar (no-op).

Source

pub fn frame_clock(&self) -> FrameClock

A frame source tied to this window, usable outside a piece build.

Source

pub fn is_open(&self) -> bool

Whether the window is still open (its record exists; a Pending open counts).

Source

pub fn on_close(&self, f: impl Fn() + 'static)

Run f after the window has closed and its content is disposed, on any close path (title-bar, platform gesture, WindowHandle::close). No-op if already closed.

Source

pub fn state(&self) -> Signal<WindowState>

The window’s display state, two ways (docs/windows.md “Window properties”): read it to follow what the user does (minimize, zoom, fullscreen), write it to ask for a state.

The platform has the last word. A write is a request; the signal settles on whatever the window actually became once the platform reports it, so a request the platform declines (a fullscreen the browser refuses outside a user gesture) reads back as the state the window kept. Probe Cap::WindowStates and Cap::WindowFullscreen before offering the controls. A cover-tier window (Cap::MultiWindow = Unsupported) stays Normal.

Source

pub fn safe_area(&self) -> Insets

This window’s safe-area insets, in points (tracked): what lies under the window’s own chrome. Nonzero for a WindowChrome::Overlay window, whose title bar sits over the content (docs/window-chrome.md), and on a phone running edge-to-edge. Unlike crate::safe_area, which resolves the window being built and otherwise the primary, this keeps answering for this window when a binding re-runs later.

Source

pub fn set_state(&self, state: WindowState)

Ask for a display state: state().set(s), spelled as an action.

Source

pub fn set_content_protected(&self, protected: bool)

Keep this window’s content out of screenshots, screen recordings and screen sharing (Cap::ContentProtection, docs/windows.md): for passwords, payment details, private messages. On iOS the content is covered while the screen is recorded or mirrored, but a screenshot still captures it.

Source

pub fn set_frame(&self, origin: Option<Point>, size: Option<Size>)

Move and/or resize the window (docs/windows.md “Window properties”): origin is the outer frame’s top-left corner on the desktop (Cap::WindowPosition), size the content size (Cap::WindowGeometry). None leaves that part alone.

Source

pub fn frame(&self) -> Option<Rect>

The window’s outer frame on the desktop, in points, where the platform says (None on a phone, under Wayland, and for a cover-tier window).

Source

pub fn set_limits(&self, min: Option<Size>, max: Option<Size>)

The content sizes the user can resize the window between (Cap::WindowGeometry).

Source

pub fn set_resizable(&self, resizable: bool)

Whether the user can resize the window (Cap::WindowGeometry).

Source

pub fn set_level(&self, level: WindowLevel)

Keep the window above other apps’ windows, or let it stack normally (Cap::WindowLevel).

Source

pub fn set_on_all_workspaces(&self, on: bool)

Show the window on every virtual desktop / Space (Cap::WindowLevel).

Source

pub fn set_skip_taskbar(&self, skip: bool)

Leave the window out of the taskbar and the window switcher (Cap::WindowLevel).

Source

pub fn set_minimizable(&self, on: bool)

Offer or withhold the window’s minimize control (Cap::WindowStates).

Source

pub fn set_maximizable(&self, on: bool)

Offer or withhold the window’s maximize / zoom control (Cap::WindowStates).

Source

pub fn set_closable(&self, on: bool)

Offer or withhold the window’s close control (Cap::WindowStates). The app can still close it with close.

Source

pub fn set_visible(&self, visible: bool)

Hide the window without closing it, or show it again (Cap::WindowStates): a palette that comes and goes, a window a status item toggles.

Source

pub fn set_appearance(&self, dark: Option<bool>)

Give this window its own light (Some(false)) or dark (Some(true)) appearance, or follow the app’s again (None). Cap::WindowAppearance; where unsupported the app-wide day::set_appearance still applies.

Source

pub fn request_attention(&self, attention: Attention)

Ask for the user’s attention: a Dock bounce, a flashing taskbar button (Cap::RequestAttention). The platform does nothing while the app is already in front.

Trait Implementations§

Source§

impl Clone for WindowHandle

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

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<T> ErasedDestructor for T
where T: 'static,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.