Skip to main content

WindowConfig

Struct WindowConfig 

Source
pub struct WindowConfig {
    pub title: String,
    pub size: Size,
    pub resizable: bool,
    pub frame_interval: Duration,
    pub present: Present,
    pub fill_monitor: bool,
    pub position: Option<Point>,
    pub maximized: bool,
    pub app_id: Option<String>,
}
Expand description

How the preview window is created.

Fields§

§title: String

Window title.

§size: Size

Initial inner size in logical pixels.

Logical, not physical, so one number describes the same amount of desk on every machine: a panel designed at 800×480 covers 800×480 of a Pi’s framebuffer and the same apparent area on a 2× Retina display, where the surface it gets is 1600×960 physical pixels. Asking in physical pixels instead is how a window ends up a quarter of its intended size on a Mac.

The surface — and therefore every coordinate the application works in — stays physical. Scaling the content to match is the application’s job, and it is handed the factor at construction by run_with.

§resizable: bool

Whether the user may resize the window.

§frame_interval: Duration

Target frame interval. Defaults to 60 Hz.

The loop sleeps until the next deadline rather than spinning, so an idle UI costs close to nothing — which is the behaviour we actually care about on the target hardware.

§present: Present

What draws the pixels. See Present.

§fill_monitor: bool

Open at the size of the monitor instead of at size.

For an application that is going to cover the screen anyway — a kiosk, a panel, anything a window manager is about to fullscreen — where asking for a window the screen cannot hold is asking to be resized on the way up. Some window managers hand such a window a size, then the size it asked for, then the size again, and what reaches the glass afterwards is not always the last of them.

Falls back to size when no monitor can be identified, which is the case on some headless and remote displays.

§position: Option<Point>

Where to put the window’s top-left, frame included, in the desktop’s physical pixels — or None to let the window manager place it.

The units are the ones InputEvent::SurfaceMoved reports in, so an application that keeps what it was last told and hands it back here opens where it closed, with nothing to convert on the way. Logical pixels are right for size and wrong for this: a desktop spanning a Retina display and a 1× one beside it has no single logical grid to name a point in.

A position no monitor covers is ignored rather than honoured — a display that has since been unplugged would otherwise open the window where nobody can reach it.

§maximized: bool

Open maximised, whatever size says.

The size is still worth setting: it is what the window goes back to when the user un-maximises it.

§app_id: Option<String>

The name the desktop knows this application by — Wayland’s app_id, X11’s WM_CLASS — or None for none.

It is what ties a window to the application’s desktop entry, so a launcher and a task bar show its name and icon, and what a window manager’s rules match. Give it the entry’s file name without .desktop: a window of squint.desktop says squint. Without one a Wayland compositor has nothing to go on, and every window rule and taskbar icon for the application is lost.

Set it on every window the application opens, the secondary ones included: each is a window of its own to the compositor. Ignored on macOS and Windows, which know an application by its bundle and its executable.

Trait Implementations§

Source§

impl Clone for WindowConfig

Source§

fn clone(&self) -> WindowConfig

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 WindowConfig

Source§

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

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

impl Default for WindowConfig

Source§

fn default() -> Self

Returns the “default value” for a type. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more