#[non_exhaustive]pub struct MainWindowOptions {
pub default_size: Option<Size<Points>>,
pub default_position: Option<WindowPosition>,
pub display: Option<DisplayId>,
pub default_mode: Option<WindowMode>,
pub default_visible: Option<bool>,
pub restore_bounds: bool,
pub attributes: WindowAttributes,
}Expand description
Launch-time options for the first app window: nsh.json "window", which
the command line writes into the app’s app.json (and the dev server’s
app info) and the runners read before any JS runs. The same keys as
WindowOptions without id, kind, parent and modal: every
attribute, defaultSize, defaultPosition, display, defaultMode
and restoreBounds. The app declares the window with <Window> or
crate::element::desktop::window() and inherits these; its own options
override them. defaultVisible is parsed but has no effect in window
model v2: the app host never shows. An unmodified window made before the
app was known (a development host’s) follows the attributes the engine
sends with the first frame (crate::Core::set_main_window).
Only standalone builds read it (their app.json). Signed packages
(.nshpkg) carry none: they run in host apps, which own their windows.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.default_size: Option<Size<Points>>Its content size when it opens.
default_position: Option<WindowPosition>Where it opens.
display: Option<DisplayId>The display it opens on (the system’s choice when it is not there).
default_mode: Option<WindowMode>The mode it opens in.
default_visible: Option<bool>Parsed for compatibility and has no effect in window model v2: the
host never shows, and the app declares its windows with <Window>
(hide one with hide()). Read at launch only.
restore_bounds: boolOpens where the user left it (the runner keeps its placement).
attributes: WindowAttributesThe attributes the app sets (the platform’s main window keeps its own for the rest: the app’s name as its title, …).
Implementations§
Source§impl MainWindowOptions
impl MainWindowOptions
Sourcepub fn kept_placement(
&self,
storage: &dyn StorageBackend,
displays: &[Display],
) -> Option<WindowPlacement>
pub fn kept_placement( &self, storage: &dyn StorageBackend, displays: &[Display], ) -> Option<WindowPlacement>
Where to open the main window with restoreBounds: the placement
the app’s last run kept in storage (the app’s own, as the engine
is given it), fitted on displays, the ones there are now. None
without restoreBounds, or with nothing kept: the window opens by
defaultSize, defaultPosition, display and defaultMode. For
the runners, before they make the window; the engine keeps the
placement as the window changes (crate::Core::set_main_window).