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: StringWindow title.
size: SizeInitial 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: boolWhether the user may resize the window.
frame_interval: DurationTarget 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: PresentWhat draws the pixels. See Present.
fill_monitor: boolOpen 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: boolOpen 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
impl Clone for WindowConfig
Source§fn clone(&self) -> WindowConfig
fn clone(&self) -> WindowConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WindowConfig
impl Debug for WindowConfig
Auto Trait Implementations§
impl Freeze for WindowConfig
impl RefUnwindSafe for WindowConfig
impl Send for WindowConfig
impl Sync for WindowConfig
impl Unpin for WindowConfig
impl UnsafeUnpin for WindowConfig
impl UnwindSafe for WindowConfig
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.