pub struct RunnerConfig {Show 14 fields
pub title: String,
pub inner_size: Size,
pub physical_size: bool,
pub prefer_software: bool,
pub startup_smoke: bool,
pub startup_full: 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: boolinner_size 是否按物理像素解释(L2 GPU 性能验收用于精确指定 1080p/4K)
prefer_software: bool强制走软件光栅器(不尝试 wgpu;用于 VM/远程桌面验证与无 GPU 环境)
startup_smoke: bool启动冒烟:窗口放到屏幕外,校验「首帧先于显示 / a11y 树在可见后推送」后自动退出
startup_full: bool完整启动路径:保留真桌面服务(单实例/托盘/菜单/快捷键),跑完启动顺序后自动退出。 这不是 smoke 的替代:两者预算与阶段标签分开归档。
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 = 不创建。启动冒烟模式跳过创建。
原生应用菜单栏;None = 不安装。当前 Windows/macOS 支持,Linux 忽略并告警。 启动冒烟模式跳过安装。
global_shortcuts: Vec<GlobalShortcut>进程级全局快捷键。启动冒烟模式跳过注册(避免占用系统快捷键)。
Implementations§
Source§impl RunnerConfig
impl RunnerConfig
pub fn new(title: impl Into<String>, width: f32, height: f32) -> Self
Sourcepub fn with_physical_size(self, physical: bool) -> Self
pub fn with_physical_size(self, physical: bool) -> Self
将 inner_size 解释为物理像素(默认逻辑像素)。
Sourcepub fn with_prefer_software(self, prefer: bool) -> Self
pub fn with_prefer_software(self, prefer: bool) -> Self
强制软件渲染(桌面应用需实现 mgui-shell-desktop::DesktopRunnerApp::create_software_backend)
Sourcepub fn with_startup_smoke(self, smoke: bool) -> Self
pub fn with_startup_smoke(self, smoke: bool) -> Self
启动冒烟模式:完成首帧 + 初始 a11y 树后自动退出,顺序不符则启动失败
Sourcepub fn with_startup_full(self, full: bool) -> Self
pub fn with_startup_full(self, full: bool) -> Self
完整启动路径:保留真桌面服务,跑完启动顺序后自动退出。
打开时同时置 startup_smoke 以复用自动退出逻辑,但不跳过桌面服务。
Sourcepub fn with_decorations(self, decorations: bool) -> Self
pub fn with_decorations(self, decorations: bool) -> Self
是否使用系统标题栏/边框(默认 true)。false 时配合
WindowShell::start_dragging / WindowShell::start_resize 自绘标题栏。
Sourcepub fn with_window_icon(self, icon: WindowIcon) -> Self
pub fn with_window_icon(self, icon: WindowIcon) -> Self
设置窗口图标(small 用于标题栏,large 用于任务栏/窗口切换器)。
Sourcepub fn with_app_id(self, id: impl Into<String>) -> Self
pub fn with_app_id(self, id: impl Into<String>) -> Self
设置桌面应用 id;Linux 下应与安装的 .desktop 文件名一致。
Sourcepub fn with_window_state_path(self, path: impl Into<PathBuf>) -> Self
pub fn with_window_state_path(self, path: impl Into<PathBuf>) -> Self
窗口大小/位置/最大化状态持久化到指定文件。
Sourcepub fn with_single_instance(self, id: impl Into<String>) -> Self
pub fn with_single_instance(self, id: impl Into<String>) -> Self
启用单实例。第二实例把命令行参数转发给第一实例并直接退出;文件关联 打开可把文件路径作为参数传入。启动冒烟模式跳过。
Sourcepub fn with_single_instance_config(self, config: SingleInstanceConfig) -> Self
pub fn with_single_instance_config(self, config: SingleInstanceConfig) -> Self
使用完整单实例配置(可关闭参数转发)。
Sourcepub fn with_tray(self, tray: TrayConfig) -> Self
pub fn with_tray(self, tray: TrayConfig) -> Self
创建系统托盘;菜单点击与图标单击回调 RunnerApp::on_tray_event。
Linux 使用 StatusNotifierItem(需要桌面支持 AppIndicator/SNI); 托盘创建失败不会阻止应用启动,只记录警告。
安装原生应用菜单栏(Windows/macOS)。菜单命令经
RunnerApp::on_native_menu_command 回调;菜单项上的加速键由宿主处理。
Sourcepub fn with_global_shortcuts(self, shortcuts: Vec<GlobalShortcut>) -> Self
pub fn with_global_shortcuts(self, shortcuts: Vec<GlobalShortcut>) -> Self
注册一组进程级全局快捷键。
Sourcepub fn with_global_shortcut(self, shortcut: GlobalShortcut) -> Self
pub fn with_global_shortcut(self, shortcut: GlobalShortcut) -> Self
追加一个进程级全局快捷键。