Skip to main content

DesktopWindow

Struct DesktopWindow 

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

桌面窗口句柄(可克隆)。

Implementations§

Source§

impl DesktopWindow

Source

pub fn new(window: Arc<Window>) -> Self

Source

pub fn with_window_identity( self, name: impl Into<String>, bus: WindowCommandBus, ) -> Self

注入多窗口宿主的跨窗命令总线与本窗口名字;由 run_multi_app 在创建槽位时调用。

Source

pub fn set_native_menu_controller( &mut self, controller: Option<Rc<dyn NativeMenuController>>, )

注入原生菜单控制器;由 desktop host 在菜单创建后调用。

Source

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

设置应用 id;Windows 系统通知会把它作为 AUMID 兜底。

Source

pub fn as_winit(&self) -> &Arc<Window> ⓘ

底层 winit 窗口——仅供 desktop host 的 GPU/AccessKit/事件循环使用。

Source

pub fn take_close_request(&self) -> bool

host 消费一次关闭请求。

Source

pub fn set_tray_available(&self, available: bool)

宿主创建/移除托盘图标后写这个开关(窗口存活期间可变,故用 Arc<AtomicBool>)。

Trait Implementations§

Source§

impl Clone for DesktopWindow

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 WindowShell for DesktopWindow

Source§

fn metrics(&self) -> ShellMetrics

Source§

fn request_redraw(&self)

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 set_title(&self, title: &str)

Source§

fn set_visible(&self, visible: bool)

Source§

fn is_visible(&self) -> bool

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

fn set_ime_allowed(&self, allowed: bool)

Source§

fn set_ime_cursor_area(&self, rect: Rect)

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 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 system_theme(&self) -> Option<SystemTheme>

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

fn high_contrast(&self) -> bool

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

fn toggle_maximized(&self)

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

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 for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more