Skip to main content

RunnerConfig

Struct RunnerConfig 

Source
pub struct RunnerConfig {
Show 13 fields pub title: String, pub inner_size: Size, pub physical_size: bool, pub prefer_software: bool, pub startup_smoke: bool, pub decorations: bool, pub window_icon: Option<WindowIcon>, pub app_id: Option<String>, pub window_state_path: Option<PathBuf>, pub single_instance: Option<SingleInstanceConfig>, pub tray: Option<TrayConfig>, pub native_menu: Option<NativeMenuBar>, pub global_shortcuts: Vec<GlobalShortcut>,
}
Expand description

窗口启动配置

Fields§

§title: String§inner_size: Size

窗口初始尺寸;默认按逻辑像素解释,physical_size = true 时按物理像素

§physical_size: bool

inner_size 是否按物理像素解释(L2 GPU 性能验收用于精确指定 1080p/4K)

§prefer_software: bool

强制走软件光栅器(不尝试 wgpu;用于 VM/远程桌面验证与无 GPU 环境)

§startup_smoke: bool

启动冒烟:窗口放到屏幕外,校验「首帧先于显示 / a11y 树在可见后推送」后自动退出

§decorations: bool

是否创建系统标题栏/边框;false 用于程序自绘菜单标题栏。

§window_icon: Option<WindowIcon>

窗口图标(small=标题栏,large=任务栏/切换器);None = 系统/exe 默认

§app_id: Option<String>

桌面应用 id(Linux 关联 .desktop;Windows 预留给 AUMID,当前未使用)

§window_state_path: Option<PathBuf>

窗口几何持久化文件;Some 时启动自动恢复、关闭时自动保存。 启动冒烟/物理像素模式不读写该文件。

§single_instance: Option<SingleInstanceConfig>

单实例守卫;None = 允许同时运行多个实例。启动冒烟模式跳过。

§tray: Option<TrayConfig>

系统托盘;None = 不创建。启动冒烟模式跳过创建。

§native_menu: Option<NativeMenuBar>

原生应用菜单栏;None = 不安装。当前 Windows/macOS 支持,Linux 忽略并告警。 启动冒烟模式跳过安装。

§global_shortcuts: Vec<GlobalShortcut>

进程级全局快捷键。启动冒烟模式跳过注册(避免占用系统快捷键)。

Implementations§

Source§

impl RunnerConfig

Source

pub fn new(title: impl Into<String>, width: f32, height: f32) -> Self

Source

pub fn with_physical_size(self, physical: bool) -> Self

将 inner_size 解释为物理像素(默认逻辑像素)。

Source

pub fn with_prefer_software(self, prefer: bool) -> Self

强制软件渲染(桌面应用需实现 mgui-shell-desktop::DesktopRunnerApp::create_software_backend)

Source

pub fn with_startup_smoke(self, smoke: bool) -> Self

启动冒烟模式:完成首帧 + 初始 a11y 树后自动退出,顺序不符则启动失败

Source

pub fn with_decorations(self, decorations: bool) -> Self

是否使用系统标题栏/边框(默认 true)。false 时配合 WindowShell::start_dragging / WindowShell::start_resize 自绘标题栏。

Source

pub fn with_window_icon(self, icon: WindowIcon) -> Self

设置窗口图标(small 用于标题栏,large 用于任务栏/窗口切换器)。

Source

pub fn with_app_id(self, id: impl Into<String>) -> Self

设置桌面应用 id;Linux 下应与安装的 .desktop 文件名一致。

Source

pub fn with_window_state_path(self, path: impl Into<PathBuf>) -> Self

窗口大小/位置/最大化状态持久化到指定文件。

Source

pub fn with_single_instance(self, id: impl Into<String>) -> Self

启用单实例。第二实例把命令行参数转发给第一实例并直接退出;文件关联 打开可把文件路径作为参数传入。启动冒烟模式跳过。

Source

pub fn with_single_instance_config(self, config: SingleInstanceConfig) -> Self

使用完整单实例配置(可关闭参数转发)。

Source

pub fn with_tray(self, tray: TrayConfig) -> Self

创建系统托盘;菜单点击与图标单击回调 RunnerApp::on_tray_event。

Linux 使用 StatusNotifierItem(需要桌面支持 AppIndicator/SNI); 托盘创建失败不会阻止应用启动,只记录警告。

Source

pub fn with_native_menu(self, menu: NativeMenuBar) -> Self

安装原生应用菜单栏(Windows/macOS)。菜单命令经 RunnerApp::on_native_menu_command 回调;菜单项上的加速键由宿主处理。

Source

pub fn with_global_shortcuts(self, shortcuts: Vec<GlobalShortcut>) -> Self

注册一组进程级全局快捷键。

Source

pub fn with_global_shortcut(self, shortcut: GlobalShortcut) -> Self

追加一个进程级全局快捷键。

Trait Implementations§

Source§

impl Clone for RunnerConfig

Source§

fn clone(&self) -> Self

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 RunnerConfig

Source§

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

Formats the value using the given formatter. 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<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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,