Skip to main content

HeadlessShell

Struct HeadlessShell 

Source
pub struct HeadlessShell { /* private fields */ }
Expand description

无窗口应用宿主。

Implementations§

Source§

impl HeadlessShell

Source

pub fn new(width: f32, height: f32) -> Self

Source

pub fn with_metrics(metrics: ShellMetrics) -> Self

Source

pub fn metrics(&self) -> ShellMetrics

Source

pub fn now_ms(&self) -> u64

Source

pub fn advance(&self, delta_ms: u64) -> u64

推进确定性时钟(不自动渲染)。

Source

pub fn set_time(&self, now_ms: u64)

Source

pub fn resize(&mut self, logical_size: Size, scale_factor: f32)

Source

pub fn mount(&mut self, root: WidgetNode)

Source

pub fn update(&mut self, root: WidgetNode)

Source

pub fn dispatch_event(&mut self, event: &WidgetEvent)

注入指针/键盘/IME 事件;坐标取事件自带 position。

Source

pub fn dispatch_event_at(&mut self, event: &WidgetEvent, position: Point)

显式指定命中坐标(Scroll / 无坐标事件等)。

Source

pub fn click(&mut self, position: Point)

Source

pub fn key_down(&mut self, key: KeyCode)

Source

pub fn key_down_with(&mut self, key: KeyCode, mods: KeyModifiers)

Source

pub fn key_up(&mut self, key: KeyCode)

Source

pub fn type_text(&mut self, text: &str)

Source

pub fn ime_commit(&mut self, text: impl Into<String>)

Source

pub fn dispatch_shell_event(&mut self, event: &ShellEvent)

注入平台无关事件——与桌面 Runner 走同一条 ShellEvent 管线。

Source

pub fn frame(&mut self) -> &RgbaImage

执行一帧:统一帧管线(tick → build requests → overlay intent)→ paint → 软件光栅化。

Source

pub fn frame_with_stats(&mut self) -> (&RgbaImage, FrameStats)

与 Self::frame 完全同一条帧管线,额外返回本帧真实 FrameStats。

供 Headless/Agent 的逐帧 motion trace 使用 —— trace 必须读管线自己产出的 统计(而非另造一份),否则“不逐帧重建 Widget“的验收就失去了意义。

Source

pub fn frame_paint(&self) -> Option<&FramePaint>

最近一帧的 PaintList(需要检查绘制命令时使用)。

Source

pub fn image(&self) -> Option<&RgbaImage>

Source

pub fn pixel(&self, x: u32, y: u32) -> Option<[u8; 4]>

Source

pub fn tree(&self) -> &ElementTree

Source

pub fn tree_mut(&mut self) -> &mut ElementTree

Source

pub fn overlay_count(&self) -> usize

Source

pub fn element_bounds(&self, id: ElementId) -> Option<Rect>

Source

pub fn a11y_snapshot(&self) -> Vec<(ElementId, SemanticsData)>

无障碍语义快照(与 Runner 推送给 AccessKit 的数据同源)。

Source

pub fn title(&self) -> String

Source

pub fn ime_allowed(&self) -> bool

Source

pub fn ime_cursor_area(&self) -> Option<Rect>

Trait Implementations§

Source§

impl FrameHost for HeadlessShell

Source§

fn tree_mut(&mut self) -> &mut ElementTree

Source§

fn wants_full_rebuild(&mut self, _viewport: Size) -> bool

本帧是否需要全树重建(宿主 peek 了全局信号等)。
Source§

fn build_root(&mut self, _viewport: Size) -> Option<WidgetNode>

构建新的 widget 树。仅在需要 mount/update 时调用。 返回 None = 本帧不做全树重建(例如 headless 由调用方手动 mount)。
Source§

fn take_pending_pointer(&mut self) -> Option<Point>

取出合并到本帧派发的指针位置(如 CursorMoved 合并)。
Source§

fn after_tick(&mut self, _now_ms: u64)

tick + build requests 之后、overlay/paint 之前的宿主钩子 (编辑器焦点移交、查找条同步等)。
Source§

impl WindowShell for HeadlessShell

Source§

fn metrics(&self) -> ShellMetrics

Source§

fn request_redraw(&self)

Source§

fn set_title(&self, title: &str)

Source§

fn set_visible(&self, _visible: bool)

Source§

fn set_ime_allowed(&self, allowed: bool)

Source§

fn set_ime_cursor_area(&self, rect: Rect)

Source§

fn is_visible(&self) -> bool

窗口当前是否可见;默认 true(headless/未知)。
Source§

fn set_cursor(&self, _cursor: CursorIcon)

光标形状;默认 no-op。
Source§

fn set_fullscreen(&self, _fullscreen: bool)

进入/退出全屏(当前显示器无边框全屏);默认 no-op。
Source§

fn is_fullscreen(&self) -> bool

Source§

fn set_minimized(&self, _minimized: bool)

最小化 / 还原;默认 no-op。
Source§

fn set_maximized(&self, _maximized: bool)

最大化 / 还原;默认 no-op。
Source§

fn is_maximized(&self) -> bool

Source§

fn focus_window(&self)

请求系统把键盘焦点移到此窗口;默认 no-op。
Source§

fn set_decorations(&self, _decorations: bool)

显示/隐藏系统标题栏与边框;默认 no-op。
Source§

fn toggle_maximized(&self)

最大化与还原之间切换。默认基于 WindowShell::is_maximized / WindowShell::set_maximized 实现。
Source§

fn start_dragging(&self) -> Result<(), String>

开始拖动窗口(用于自绘标题栏)。由左键按下事件触发,系统接管直到释放。 默认返回不支持错误(headless / 平台无此能力)。
Source§

fn start_resize(&self, _direction: ResizeDirection) -> Result<(), String>

开始拖动窗口边缘缩放(用于无边框/自绘标题栏)。 Read more
Source§

fn set_resizable(&self, _resizable: bool)

是否允许用户拖拽调整窗口大小;默认 no-op。
Source§

fn set_always_on_top(&self, _on_top: bool)

置顶 / 取消置顶;默认 no-op。
Source§

fn set_size(&self, _size: Size)

设置客户区逻辑尺寸;默认 no-op。
Source§

fn set_position(&self, _x: f32, _y: f32)

设置窗口左上角逻辑位置;默认 no-op。
Source§

fn request_close(&self)

请求关闭当前窗口。应用在 on_close_requested 里确认后调用; 默认 no-op(headless / 不支持关闭的 shell)。
Source§

fn tray_available(&self) -> bool

本进程是否真的有一个可用的系统托盘图标。默认 false(headless / 未配置托盘)。 Read more
Source§

fn window_name(&self) -> Option<String>

本窗口在 MultiWindowConfig 里的名字(WindowSpec::with_name)。 单窗口 / headless 默认 None。
Source§

fn send_window_command( &self, _window: &str, _command: WindowCommand, ) -> Result<(), String>

向同一次 run_multi_app 里的另一个窗口投递命令(按窗口名寻址)。 Read more
Source§

fn system_theme(&self) -> Option<SystemTheme>

当前系统明暗主题;None = 平台不支持或未知。
Source§

fn clipboard(&self) -> ClipboardHandle

系统剪贴板句柄(可克隆,支持文本/HTML/图片/文件列表)。 Read more
Source§

fn native_menu(&self) -> Option<Rc<dyn NativeMenuController>>

已安装的原生菜单控制器;None = 未安装/平台不支持。
Source§

fn set_undecorated_shadow(&self, _shadow: bool)

无边框窗口是否启用系统投影(Windows 10 2004+;其他平台 no-op)。 Read more
Source§

fn high_contrast(&self) -> bool

当前系统是否启用高对比度(Windows 读取注册表;其他平台暂返回 false)。 Read more
Source§

fn set_window_corners(&self, _corners: WindowCorners)

设置窗口圆角样式(Windows 11+;其他平台 no-op)。 Read more
Source§

fn window_state(&self) -> Option<WindowState>

当前窗口几何状态;None = 平台不支持(headless / 尚未创建)。
Source§

fn pick_file(&self, _options: &FileDialogOptions) -> Option<PathBuf>

原生“打开文件”对话框。阻塞调用,应在 UI 线程直接调用并处理返回值。 默认 None(headless / 不支持)。
Source§

fn pick_files(&self, _options: &FileDialogOptions) -> Option<Vec<PathBuf>>

原生“打开多个文件”对话框。
Source§

fn pick_folder(&self, _options: &FileDialogOptions) -> Option<PathBuf>

原生“选择文件夹”对话框。
Source§

fn save_file(&self, _options: &FileDialogOptions) -> Option<PathBuf>

原生“保存文件”对话框。
Source§

fn start_file_drag( &self, _paths: &[PathBuf], _options: &FileDragOptions, ) -> Result<FileDragOutcome, String>

从窗口拖出文件(资源管理器/Finder/文件接收应用)。 Read more
Source§

fn show_notification(&self, _notification: &Notification) -> Result<(), String>

发送系统通知。同步调用,通常在毫秒级完成;通知服务不可用时返回错误。 默认返回不支持错误(headless / 无通知服务的 shell)。

Auto Trait Implementations§

§

impl !Freeze for HeadlessShell

§

impl !RefUnwindSafe for HeadlessShell

§

impl !Send for HeadlessShell

§

impl !Sync for HeadlessShell

§

impl !UnwindSafe for HeadlessShell

§

impl Forget for HeadlessShell

§

impl Move for HeadlessShell

§

impl Unpin for HeadlessShell
where *const u8 is !null: Unpin, NonZero<u32>: Unpin, Rc<dyn Widget>: Unpin, Rc<RoCell>: Unpin, Box<dyn State>: Unpin, *const (): Unpin, Rc<PaintList>: Unpin, Align1<u8>: Unpin, Align4<u32>: Unpin, &'static str: Unpin, Rc<RefCell<SoftwareRenderer>>: Unpin, Rc<ManualClock>: Unpin,

§

impl UnsafeUnpin for HeadlessShell

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<T> ErasedDestructor for T
where T: 'static,

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, 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.