pub trait WindowIdExt: WindowIdExtSealed {
Show 22 methods
// Required methods
fn bounds_on_screen_including_frame(&self) -> Option<Rect>;
fn bounds_of_content_on_screen(&self) -> Option<Rect>;
fn position_on_screen_including_frame(&self) -> Option<Point>;
fn position_of_content_on_screen(&self) -> Option<Point>;
fn monitor_bounds(&self) -> Option<Rect>;
fn is_visible(&self) -> bool;
fn is_minimized(&self) -> bool;
fn is_maximized(&self) -> bool;
fn is_document_edited(&self) -> bool;
fn force_repaint(&self) -> bool;
fn root_view(&self) -> Option<ViewId>;
fn screen_layout(&self) -> Option<ScreenLayout>;
fn scale(&self) -> f64;
// Provided methods
fn set_document_edited(&self, edited: bool) { ... }
fn set_visible(&self, visible: bool) { ... }
fn set_window_inner_bounds(&self, bounds: Rect) { ... }
fn set_window_outer_bounds(&self, bounds: Rect) { ... }
fn maximized(&self, maximized: bool) { ... }
fn minimized(&self, minimized: bool) { ... }
fn set_outer_location(&self, location: Point) { ... }
fn set_content_size(&self, size: Size) { ... }
fn request_attention(&self, urgency: Urgency) { ... }
}
Expand description
Extends WindowId
to give instances methods to retrieve properties of the associated window,
much as ViewId
does.
Methods may return None if the view is not realized on-screen, or if information needed to compute the result is not available on the current platform or available on the current platform but not from the calling thread.
Platform support notes:
- macOS: Many of the methods here, if called from a thread other than
main
, are blocking because accessing most window properties may only be done from the main thread on that OS. - Android & Wayland: Getting the outer position of a window is not supported by
winit
and methods whose return value have that as a prerequisite will returnNone
or return a reasonable default. - X11: Some window managers (Openbox was one such which was tested) appear to support retrieving separate window-with-frame and window-content positions and sizes, but in fact report the same values for both.
Required Methods§
Sourcefn bounds_on_screen_including_frame(&self) -> Option<Rect>
fn bounds_on_screen_including_frame(&self) -> Option<Rect>
Get the bounds of the content of this window, including titlebar and native window borders.
Sourcefn bounds_of_content_on_screen(&self) -> Option<Rect>
fn bounds_of_content_on_screen(&self) -> Option<Rect>
Get the bounds of the content of this window, excluding titlebar and native window borders.
Sourcefn position_on_screen_including_frame(&self) -> Option<Point>
fn position_on_screen_including_frame(&self) -> Option<Point>
Get the location of the window including any OS titlebar.
Sourcefn position_of_content_on_screen(&self) -> Option<Point>
fn position_of_content_on_screen(&self) -> Option<Point>
Get the location of the window’s content on the monitor where it currently resides, excluding any OS titlebar.
Sourcefn monitor_bounds(&self) -> Option<Rect>
fn monitor_bounds(&self) -> Option<Rect>
Get the logical bounds of the monitor this window is on.
Sourcefn is_visible(&self) -> bool
fn is_visible(&self) -> bool
Determine if this window is currently visible. Note that if a call to set a window visible which is invisible has happened within the current event loop cycle, the state returned will not reflect that.
Sourcefn is_minimized(&self) -> bool
fn is_minimized(&self) -> bool
Determine if this window is currently minimized. Note that if a call to minimize or unminimize this window, and it is currently in the opposite state, has happened the current event loop cycle, the state returned will not reflect that.
Sourcefn is_maximized(&self) -> bool
fn is_maximized(&self) -> bool
Determine if this window is currently maximize. Note that if a call to maximize or unmaximize this window, and it is currently in the opposite state, has happened the current event loop cycle, the state returned will not reflect that.
Sourcefn is_document_edited(&self) -> bool
fn is_document_edited(&self) -> bool
Determine if the window decorations should indicate an edited, unsaved
document. Platform-dependent: Will only ever return true
on macOS.
Sourcefn force_repaint(&self) -> bool
fn force_repaint(&self) -> bool
Force a repaint of this window through the native window’s repaint mechanism, bypassing floem’s normal repaint mechanism.
This method may be removed or deprecated in the future, but has been needed
in some situations, and to
address a few ongoing issues in winit
(window unmaximize is delayed until
an external event triggers a repaint of the requesting window), and may
be needed as a workaround if other such issues are discovered until they
can be addressed.
Returns true if the repaint request was issued successfully (i.e. there is
an actual system-level window corresponding to this WindowId
).
Sourcefn screen_layout(&self) -> Option<ScreenLayout>
fn screen_layout(&self) -> Option<ScreenLayout>
Get a layout of this window in relation to the monitor on which it currently resides, if any.
Provided Methods§
Sourcefn set_document_edited(&self, edited: bool)
fn set_document_edited(&self, edited: bool)
Instruct the window manager to indicate in the window’s decorations that the window contains an unsaved, edited document. Only has an effect on macOS.
Sourcefn set_visible(&self, visible: bool)
fn set_visible(&self, visible: bool)
Set this window’s visible state, hiding or showing it if it has been hidden
Sourcefn set_window_inner_bounds(&self, bounds: Rect)
fn set_window_inner_bounds(&self, bounds: Rect)
Update the bounds of this window.
Sourcefn set_window_outer_bounds(&self, bounds: Rect)
fn set_window_outer_bounds(&self, bounds: Rect)
Update the bounds of this window.
Sourcefn set_outer_location(&self, location: Point)
fn set_outer_location(&self, location: Point)
Change this window’s minimized state.
Sourcefn set_content_size(&self, size: Size)
fn set_content_size(&self, size: Size)
Ask the OS’s windowing framework to update the size of the window based on the passed size for its content (excluding titlebar, frame or other decorations).
Sourcefn request_attention(&self, urgency: Urgency)
fn request_attention(&self, urgency: Urgency)
Cause the desktop to perform some attention-drawing behavior that draws
the user’s attention specifically to this window - e.g. bouncing in
the dock on macOS. On X11, after calling this method with some urgency
other than None
, it is necessary to clear the attention-seeking state
by calling this method again with Urgency::None
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.