pub struct WindowHandle { /* private fields */ }Expand description
A live secondary window (docs/windows.md). Cheap to clone; inert after close.
Implementations§
Source§impl WindowHandle
impl WindowHandle
Sourcepub fn set_content_scope(&self, scope: Scope)
pub fn set_content_scope(&self, scope: Scope)
Bind command/ambient lookup to retained document state without transferring scope ownership.
Sourcepub fn on_close_request(&self, f: impl Fn() + 'static)
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.
Sourcepub fn on_focus(&self, f: impl Fn() + 'static)
pub fn on_focus(&self, f: impl Fn() + 'static)
Observe native activation (including selection of an OS window tab).
Sourcepub fn tab_order(&self) -> Vec<NodeId>
pub fn tab_order(&self) -> Vec<NodeId>
Native order of this window’s tab group. Empty where unsupported.
Sourcepub fn close(&self)
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.
Sourcepub fn focus(&self)
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.
Sourcepub fn set_title(&self, title: &str)
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).
Sourcepub fn frame_clock(&self) -> FrameClock
pub fn frame_clock(&self) -> FrameClock
A frame source tied to this window, usable outside a piece build.
Sourcepub fn is_open(&self) -> bool
pub fn is_open(&self) -> bool
Whether the window is still open (its record exists; a Pending open counts).
Sourcepub fn on_close(&self, f: impl Fn() + 'static)
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.
Sourcepub fn state(&self) -> Signal<WindowState>
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.
Sourcepub fn safe_area(&self) -> Insets
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.
Sourcepub fn set_state(&self, state: WindowState)
pub fn set_state(&self, state: WindowState)
Ask for a display state: state().set(s), spelled as an action.
Sourcepub fn set_content_protected(&self, protected: bool)
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.
Sourcepub fn set_frame(&self, origin: Option<Point>, size: Option<Size>)
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.
Sourcepub fn frame(&self) -> Option<Rect>
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).
Sourcepub fn set_limits(&self, min: Option<Size>, max: Option<Size>)
pub fn set_limits(&self, min: Option<Size>, max: Option<Size>)
The content sizes the user can resize the window between (Cap::WindowGeometry).
Sourcepub fn set_resizable(&self, resizable: bool)
pub fn set_resizable(&self, resizable: bool)
Whether the user can resize the window (Cap::WindowGeometry).
Sourcepub fn set_level(&self, level: WindowLevel)
pub fn set_level(&self, level: WindowLevel)
Keep the window above other apps’ windows, or let it stack normally (Cap::WindowLevel).
Sourcepub fn set_on_all_workspaces(&self, on: bool)
pub fn set_on_all_workspaces(&self, on: bool)
Show the window on every virtual desktop / Space (Cap::WindowLevel).
Sourcepub fn set_skip_taskbar(&self, skip: bool)
pub fn set_skip_taskbar(&self, skip: bool)
Leave the window out of the taskbar and the window switcher (Cap::WindowLevel).
Sourcepub fn set_minimizable(&self, on: bool)
pub fn set_minimizable(&self, on: bool)
Offer or withhold the window’s minimize control (Cap::WindowStates).
Sourcepub fn set_maximizable(&self, on: bool)
pub fn set_maximizable(&self, on: bool)
Offer or withhold the window’s maximize / zoom control (Cap::WindowStates).
Sourcepub fn set_closable(&self, on: bool)
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.
Sourcepub fn set_visible(&self, visible: bool)
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.
Sourcepub fn set_appearance(&self, dark: Option<bool>)
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.
Sourcepub fn request_attention(&self, attention: Attention)
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§
Auto Trait Implementations§
impl Freeze for WindowHandle
impl RefUnwindSafe for WindowHandle
impl Send for WindowHandle
impl Sync for WindowHandle
impl Unpin for WindowHandle
impl UnsafeUnpin for WindowHandle
impl UnwindSafe for WindowHandle
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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