pub struct WindowOptions {Show 13 fields
pub title: String,
pub size: Size,
pub clear_color: Color,
pub repaint: RepaintMode,
pub show_damage: bool,
pub renderer: RendererChoice,
pub stats: Option<PresentStatsHandle>,
pub on_frame: Option<FrameHook>,
pub on_event: Option<EventHook>,
pub frame_limit: Option<u64>,
pub decorations: bool,
pub min_size: Option<Size>,
pub app_id: Option<String>,
}Expand description
The settings a window opens with.
Fields§
§title: StringThe text shown in the window’s title bar.
size: SizeThe size of the window’s content area in logical pixels.
clear_color: ColorThe color the renderer fills the surface with before it replays the display list.
Must be opaque, because presentation copies only the color channels of
the surface into the window. A run with a color that is not opaque
returns PlatformError::ClearColor before a window opens.
repaint: RepaintModeHow much of the surface each frame repaints.
show_damage: boolWhether every present tints the pixels the frame repainted.
A debugging aid for damage regressions: while it is on, every present copies the whole pixmap and blends a translucent tint over the frame’s damage rectangles in the window buffer alone, so the window shows what each frame paid for. Damage presentation is off while the overlay is on, and neither the renderer’s pixmap nor a later frame keeps a tint.
The overlay exists on the CPU renderer only, so it makes
RendererChoice::Auto pick the CPU renderer, and it cannot be
combined with RendererChoice::Gpu.
renderer: RendererChoiceWhich renderer presents the frames.
RendererChoice::Auto uses the GPU renderer only when the window’s
adapter is a real GPU, and falls back to the CPU renderer on a software
rasterizer, without one, or on a window the GPU cannot present to. It
is the default in builds with the gpu feature. RendererChoice::Gpu
never falls back to the CPU renderer: it fails the run when the gpu
feature is off or no backend, OpenGL included, has a usable adapter.
The crate::renderer::RENDERER_ENVIRONMENT variable, set to cpu,
gpu or auto, overrides the value here when the window opens, so a
machine can switch renderer without a rebuild.
stats: Option<PresentStatsHandle>Where the platform publishes presentation statistics, when given.
Pass a PresentStatsHandle and keep the original to read the
PresentStats of the most recent present while the window runs.
Without one the platform skips publishing.
on_frame: Option<FrameHook>Measurement hook: runs after every presented frame.
The hook receives the frame’s FrameStats and the present’s
PresentStats, in that order. It runs on the main thread between
frames and must not touch the window. A frame rendered while the
surface has no pixel, for example while the window is minimized, is not
presented, so it neither calls the hook nor counts toward the frame
limit.
on_event: Option<EventHook>Measurement hook: injects input before every frame.
The hook receives the app and may hand it input events through
App::handle_event, which is the path every real event takes, so the
frame that follows shows the event and measures its latency. A run with
this hook draws frames back to back like a run with a tick. Like a
ticked frame, a frame whose input changed nothing presents nothing, so
it neither calls WindowOptions::on_frame nor counts toward the
frame limit. A hook that must reach its limit changes something in
every frame.
frame_limit: Option<u64>Measurement hook: closes the window after this many presented frames.
A run that must last a fixed number of frames sets this instead of waiting for the user to close the window. Until the limit is reached, every presented frame asks for the next one, as if the app ran a tick, so a window whose app has nothing more to draw still closes: such a frame presents the last picture again, paced by the display. A frame that presents nothing, because the surface has no pixels to show, asks for none, so the run waits for the window to change instead of spinning.
decorations: boolWhether the window system draws its own decorations around the window.
An application that draws its own title bar turns this off and starts moves and resizes itself through the window commands.
min_size: Option<Size>The smallest size the user can resize the window to, in logical pixels.
None, the default, puts no limit on the resize.
app_id: Option<String>The name the window system reports for the application.
On Wayland this is the xdg_toplevel app id, and on X11 both parts of
the WM_CLASS, so a desktop can match the window to a .desktop entry.
On the other platforms the field has no effect.
Trait Implementations§
Source§impl Clone for WindowOptions
impl Clone for WindowOptions
Source§impl Debug for WindowOptions
impl Debug for WindowOptions
Auto Trait Implementations§
impl !RefUnwindSafe for WindowOptions
impl !Send for WindowOptions
impl !Sync for WindowOptions
impl !UnwindSafe for WindowOptions
impl Forget for WindowOptions
impl Freeze for WindowOptions
impl Move for WindowOptions
impl Unpin for WindowOptions
impl UnsafeUnpin for WindowOptions
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.