pub struct DesktopConfig {
pub app_name: Option<String>,
pub app_id: Option<String>,
pub window_icon: Option<IconData>,
pub menu_spec: Option<MenuSpec>,
pub quit_on_last_window_closed: bool,
}Expand description
The desktop app’s identity and native-integration vocabulary, re-exported
from the desktop core so app code never names a shell crate:
DesktopConfig (the whole declaration — app name, reverse-DNS id, window
icon, menu bar, last-window-close policy — handed to App::desktop,
run_desktop_config or app!’s desktop = { .. } argument),
MenuSpec/MenuItemSpec/MenuRole (the platform-independent native
menu tree a per-OS shell translates into an NSApp menu bar or an HMENU),
DesktopIconData (decoded, tightly-packed RGBA8 — decoding a
PNG/ICO/ICNS is the caller’s job), and DEFAULT_APP_NAME (the window
title a config that names nothing still gets).
frust-shell-desktop‘s IconData is re-exported renamed: the facade
already carries frust-widgets’ IconData, an in-UI vector icon, and the
two are unrelated (one is a BezPath a widget paints, the other is the
window/taskbar bitmap the OS shows). The Desktop prefix matches
DesktopConfig, whose with_window_icon is its only consumer.
use frust::{DesktopConfig, MenuItemSpec, MenuRole, MenuSpec};
let file = MenuSpec::new()
.with_item(MenuItemSpec::item("file.open", "Open…").with_accelerator("CmdOrCtrl+O"))
.with_item(MenuItemSpec::separator())
.with_item(MenuItemSpec::role(MenuRole::Quit));
let config = DesktopConfig::new()
.with_app_name("Huddle")
.with_app_id("dev.frust.huddle")
.with_menu_spec(MenuSpec::new().with_item(MenuItemSpec::submenu("File", file)));Desktop-only, unlike the menu_events read side: these types are
defined in frust-shell-desktop, which is not in a mobile build’s or a
wasm32 build’s dependency graph at all (see this crate’s Cargo.toml).
Code shared with a mobile or wasm32 target keeps a DesktopConfig behind
its own
#[cfg(not(any(target_os = "android", target_os = "ios", target_arch = "wasm32")))]
— or, more simply, writes it inline in app!’s desktop = { .. }
argument, which the macro already emits only on the targets that have it.
The desktop app’s identity and native-integration configuration.
Built by the facade from an app’s own declaration and handed to
run_desktop_with; every field is optional and
the Default value is today’s dev-preview behavior (see the module docs).
Fields§
§app_name: Option<String>The app’s display name: the window title, and (for the per-OS shells)
the name a macOS menu bar’s application menu shows. None falls back to
DEFAULT_APP_NAME for the title — see DesktopConfig::window_title.
app_id: Option<String>The app’s reverse-DNS identifier (com.example.myapp). Carried, never
consumed by the shared core: the Linux shell turns it into a Wayland
app_id/X11 WM_CLASS so the window pairs with its .desktop entry,
and the Windows shell into an AppUserModelID so taskbar grouping and
notifications attribute correctly.
window_icon: Option<IconData>The window/taskbar icon as platform-independent RGBA (see IconData).
Carried for the per-OS shells; the shared core never attaches it, since
winit’s own WindowAttributes::with_window_icon reaches X11 and Windows
only and macOS wants an application icon rather than a window one.
The native menu bar to install, if any (see MenuSpec). Carried for
the per-OS shells that can build one; a platform with no native menu
(Linux, where the menu is widget-drawn) simply ignores it.
quit_on_last_window_closed: boolWhether closing the last window quits the app.
Carried, not consumed by the shared core: with no extension installed a
close request always exits the event loop (today’s behavior, and what
true means anyway). It exists for the macOS shell, where the platform
convention is for an app to stay running with no window until ⌘Q —
see DesktopExtensions::on_close_requested.
Implementations§
Source§impl DesktopConfig
impl DesktopConfig
Sourcepub fn new() -> DesktopConfig
pub fn new() -> DesktopConfig
A config that reproduces today’s zero-config preview window (see
Default).
Sourcepub fn with_app_name(self, app_name: impl Into<String>) -> DesktopConfig
pub fn with_app_name(self, app_name: impl Into<String>) -> DesktopConfig
Set the app’s display name (the window title).
Sourcepub fn with_app_id(self, app_id: impl Into<String>) -> DesktopConfig
pub fn with_app_id(self, app_id: impl Into<String>) -> DesktopConfig
Set the app’s reverse-DNS identifier.
Sourcepub fn with_window_icon(self, icon: IconData) -> DesktopConfig
pub fn with_window_icon(self, icon: IconData) -> DesktopConfig
Set the window/taskbar icon.
Set the native menu bar to install.
Sourcepub fn with_quit_on_last_window_closed(self, quit: bool) -> DesktopConfig
pub fn with_quit_on_last_window_closed(self, quit: bool) -> DesktopConfig
Set whether closing the last window quits the app.
Sourcepub fn window_title(&self) -> &str
pub fn window_title(&self) -> &str
The title to give the preview window: the configured
app_name, else DEFAULT_APP_NAME.
The fallback lives here rather than in the field itself so a per-OS
shell can still tell “the app named itself Frust” apart from “the app
named itself nothing” — a macOS menu bar wants the real name or no
application menu at all, not a placeholder.
Trait Implementations§
Source§impl Clone for DesktopConfig
impl Clone for DesktopConfig
Source§fn clone(&self) -> DesktopConfig
fn clone(&self) -> DesktopConfig
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 DesktopConfig
impl Debug for DesktopConfig
Source§impl Default for DesktopConfig
impl Default for DesktopConfig
Source§fn default() -> DesktopConfig
fn default() -> DesktopConfig
Hand-written rather than derived because
quit_on_last_window_closed
defaults to true — the shell’s existing unconditional
event_loop.exit() on CloseRequested.
impl Eq for DesktopConfig
Source§impl PartialEq for DesktopConfig
impl PartialEq for DesktopConfig
impl StructuralPartialEq for DesktopConfig
Auto Trait Implementations§
impl Freeze for DesktopConfig
impl RefUnwindSafe for DesktopConfig
impl Send for DesktopConfig
impl Sync for DesktopConfig
impl Unpin for DesktopConfig
impl UnsafeUnpin for DesktopConfig
impl UnwindSafe for DesktopConfig
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<T> Brush for 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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.