pub trait WindowDispatch<T: UserEvent>:
Debug
+ Clone
+ Send
+ Sync
+ Sized
+ 'static {
type Runtime: Runtime<T>;
type WindowBuilder: WindowBuilder;
Show 71 methods
// Required methods
fn run_on_main_thread<F: FnOnce() + Send + 'static>(
&self,
f: F,
) -> Result<()>;
fn on_window_event<F: Fn(&WindowEvent) + Send + 'static>(
&self,
f: F,
) -> WindowEventId;
fn scale_factor(&self) -> Result<f64>;
fn inner_position(&self) -> Result<PhysicalPosition<i32>>;
fn outer_position(&self) -> Result<PhysicalPosition<i32>>;
fn inner_size(&self) -> Result<PhysicalSize<u32>>;
fn outer_size(&self) -> Result<PhysicalSize<u32>>;
fn is_fullscreen(&self) -> Result<bool>;
fn is_minimized(&self) -> Result<bool>;
fn is_maximized(&self) -> Result<bool>;
fn is_focused(&self) -> Result<bool>;
fn is_decorated(&self) -> Result<bool>;
fn is_resizable(&self) -> Result<bool>;
fn is_maximizable(&self) -> Result<bool>;
fn is_minimizable(&self) -> Result<bool>;
fn is_closable(&self) -> Result<bool>;
fn is_visible(&self) -> Result<bool>;
fn is_enabled(&self) -> Result<bool>;
fn title(&self) -> Result<String>;
fn current_monitor(&self) -> Result<Option<Monitor>>;
fn primary_monitor(&self) -> Result<Option<Monitor>>;
fn monitor_from_point(&self, x: f64, y: f64) -> Result<Option<Monitor>>;
fn available_monitors(&self) -> Result<Vec<Monitor>>;
fn gtk_window(&self) -> Result<ApplicationWindow>;
fn default_vbox(&self) -> Result<Box>;
fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>;
fn theme(&self) -> Result<Theme>;
fn center(&self) -> Result<()>;
fn request_user_attention(
&self,
request_type: Option<UserAttentionType>,
) -> Result<()>;
fn create_window<F: Fn(RawWindow<'_>) + Send + 'static>(
&mut self,
pending: PendingWindow<T, Self::Runtime>,
after_window_creation: Option<F>,
) -> Result<DetachedWindow<T, Self::Runtime>>;
fn create_webview(
&mut self,
pending: PendingWebview<T, Self::Runtime>,
) -> Result<DetachedWebview<T, Self::Runtime>>;
fn set_resizable(&self, resizable: bool) -> Result<()>;
fn set_enabled(&self, enabled: bool) -> Result<()>;
fn set_maximizable(&self, maximizable: bool) -> Result<()>;
fn set_minimizable(&self, minimizable: bool) -> Result<()>;
fn set_closable(&self, closable: bool) -> Result<()>;
fn set_title<S: Into<String>>(&self, title: S) -> Result<()>;
fn maximize(&self) -> Result<()>;
fn unmaximize(&self) -> Result<()>;
fn minimize(&self) -> Result<()>;
fn unminimize(&self) -> Result<()>;
fn show(&self) -> Result<()>;
fn hide(&self) -> Result<()>;
fn close(&self) -> Result<()>;
fn destroy(&self) -> Result<()>;
fn set_decorations(&self, decorations: bool) -> Result<()>;
fn set_shadow(&self, enable: bool) -> Result<()>;
fn set_always_on_bottom(&self, always_on_bottom: bool) -> Result<()>;
fn set_always_on_top(&self, always_on_top: bool) -> Result<()>;
fn set_visible_on_all_workspaces(
&self,
visible_on_all_workspaces: bool,
) -> Result<()>;
fn set_background_color(&self, color: Option<Color>) -> Result<()>;
fn set_content_protected(&self, protected: bool) -> Result<()>;
fn set_size(&self, size: Size) -> Result<()>;
fn set_min_size(&self, size: Option<Size>) -> Result<()>;
fn set_max_size(&self, size: Option<Size>) -> Result<()>;
fn set_size_constraints(
&self,
constraints: WindowSizeConstraints,
) -> Result<()>;
fn set_position(&self, position: Position) -> Result<()>;
fn set_fullscreen(&self, fullscreen: bool) -> Result<()>;
fn set_focus(&self) -> Result<()>;
fn set_icon(&self, icon: Icon<'_>) -> Result<()>;
fn set_skip_taskbar(&self, skip: bool) -> Result<()>;
fn set_cursor_grab(&self, grab: bool) -> Result<()>;
fn set_cursor_visible(&self, visible: bool) -> Result<()>;
fn set_cursor_icon(&self, icon: CursorIcon) -> Result<()>;
fn set_cursor_position<Pos: Into<Position>>(
&self,
position: Pos,
) -> Result<()>;
fn set_ignore_cursor_events(&self, ignore: bool) -> Result<()>;
fn start_dragging(&self) -> Result<()>;
fn start_resize_dragging(&self, direction: ResizeDirection) -> Result<()>;
fn set_progress_bar(&self, progress_state: ProgressBarState) -> Result<()>;
fn set_title_bar_style(&self, style: TitleBarStyle) -> Result<()>;
fn set_theme(&self, theme: Option<Theme>) -> Result<()>;
}
Expand description
Window dispatcher. A thread-safe handle to the window APIs.
Required Associated Types§
Sourcetype Runtime: Runtime<T>
type Runtime: Runtime<T>
The runtime this WindowDispatch
runs under.
Sourcetype WindowBuilder: WindowBuilder
type WindowBuilder: WindowBuilder
The window builder type.
Required Methods§
Sourcefn run_on_main_thread<F: FnOnce() + Send + 'static>(&self, f: F) -> Result<()>
fn run_on_main_thread<F: FnOnce() + Send + 'static>(&self, f: F) -> Result<()>
Run a task on the main thread.
Sourcefn on_window_event<F: Fn(&WindowEvent) + Send + 'static>(
&self,
f: F,
) -> WindowEventId
fn on_window_event<F: Fn(&WindowEvent) + Send + 'static>( &self, f: F, ) -> WindowEventId
Registers a window event handler.
Sourcefn scale_factor(&self) -> Result<f64>
fn scale_factor(&self) -> Result<f64>
Returns the scale factor that can be used to map logical pixels to physical pixels, and vice versa.
Sourcefn inner_position(&self) -> Result<PhysicalPosition<i32>>
fn inner_position(&self) -> Result<PhysicalPosition<i32>>
Returns the position of the top-left hand corner of the window’s client area relative to the top-left hand corner of the desktop.
Sourcefn outer_position(&self) -> Result<PhysicalPosition<i32>>
fn outer_position(&self) -> Result<PhysicalPosition<i32>>
Returns the position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
Sourcefn inner_size(&self) -> Result<PhysicalSize<u32>>
fn inner_size(&self) -> Result<PhysicalSize<u32>>
Returns the physical size of the window’s client area.
The client area is the content of the window, excluding the title bar and borders.
Sourcefn outer_size(&self) -> Result<PhysicalSize<u32>>
fn outer_size(&self) -> Result<PhysicalSize<u32>>
Returns the physical size of the entire window.
These dimensions include the title bar and borders. If you don’t want that (and you usually don’t), use inner_size instead.
Sourcefn is_fullscreen(&self) -> Result<bool>
fn is_fullscreen(&self) -> Result<bool>
Gets the window’s current fullscreen state.
Sourcefn is_minimized(&self) -> Result<bool>
fn is_minimized(&self) -> Result<bool>
Gets the window’s current minimized state.
Sourcefn is_maximized(&self) -> Result<bool>
fn is_maximized(&self) -> Result<bool>
Gets the window’s current maximized state.
Sourcefn is_focused(&self) -> Result<bool>
fn is_focused(&self) -> Result<bool>
Gets the window’s current focus state.
Sourcefn is_decorated(&self) -> Result<bool>
fn is_decorated(&self) -> Result<bool>
Gets the window’s current decoration state.
Sourcefn is_resizable(&self) -> Result<bool>
fn is_resizable(&self) -> Result<bool>
Gets the window’s current resizable state.
Sourcefn is_maximizable(&self) -> Result<bool>
fn is_maximizable(&self) -> Result<bool>
Gets the window’s native maximize button state.
§Platform-specific
- Linux / iOS / Android: Unsupported.
Sourcefn is_minimizable(&self) -> Result<bool>
fn is_minimizable(&self) -> Result<bool>
Gets the window’s native minimize button state.
§Platform-specific
- Linux / iOS / Android: Unsupported.
Sourcefn is_closable(&self) -> Result<bool>
fn is_closable(&self) -> Result<bool>
Sourcefn is_visible(&self) -> Result<bool>
fn is_visible(&self) -> Result<bool>
Gets the window’s current visibility state.
Sourcefn is_enabled(&self) -> Result<bool>
fn is_enabled(&self) -> Result<bool>
Whether the window is enabled or disable.
Sourcefn current_monitor(&self) -> Result<Option<Monitor>>
fn current_monitor(&self) -> Result<Option<Monitor>>
Returns the monitor on which the window currently resides.
Returns None if current monitor can’t be detected.
Sourcefn primary_monitor(&self) -> Result<Option<Monitor>>
fn primary_monitor(&self) -> Result<Option<Monitor>>
Returns the primary monitor of the system.
Returns None if it can’t identify any monitor as a primary one.
Sourcefn monitor_from_point(&self, x: f64, y: f64) -> Result<Option<Monitor>>
fn monitor_from_point(&self, x: f64, y: f64) -> Result<Option<Monitor>>
Returns the monitor that contains the given point.
Sourcefn available_monitors(&self) -> Result<Vec<Monitor>>
fn available_monitors(&self) -> Result<Vec<Monitor>>
Returns the list of all the monitors available on the system.
Sourcefn gtk_window(&self) -> Result<ApplicationWindow>
fn gtk_window(&self) -> Result<ApplicationWindow>
Returns the ApplicationWindow
from gtk crate that is used by this window.
Sourcefn default_vbox(&self) -> Result<Box>
fn default_vbox(&self) -> Result<Box>
Returns the vertical gtk::Box
that is added by default as the sole child of this window.
Sourcefn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
Raw window handle.
Sourcefn request_user_attention(
&self,
request_type: Option<UserAttentionType>,
) -> Result<()>
fn request_user_attention( &self, request_type: Option<UserAttentionType>, ) -> Result<()>
Requests user attention to the window.
Providing None
will unset the request for user attention.
Sourcefn create_window<F: Fn(RawWindow<'_>) + Send + 'static>(
&mut self,
pending: PendingWindow<T, Self::Runtime>,
after_window_creation: Option<F>,
) -> Result<DetachedWindow<T, Self::Runtime>>
fn create_window<F: Fn(RawWindow<'_>) + Send + 'static>( &mut self, pending: PendingWindow<T, Self::Runtime>, after_window_creation: Option<F>, ) -> Result<DetachedWindow<T, Self::Runtime>>
Create a new window.
Sourcefn create_webview(
&mut self,
pending: PendingWebview<T, Self::Runtime>,
) -> Result<DetachedWebview<T, Self::Runtime>>
fn create_webview( &mut self, pending: PendingWebview<T, Self::Runtime>, ) -> Result<DetachedWebview<T, Self::Runtime>>
Create a new webview.
Sourcefn set_resizable(&self, resizable: bool) -> Result<()>
fn set_resizable(&self, resizable: bool) -> Result<()>
Updates the window resizable flag.
Sourcefn set_enabled(&self, enabled: bool) -> Result<()>
fn set_enabled(&self, enabled: bool) -> Result<()>
Sourcefn set_maximizable(&self, maximizable: bool) -> Result<()>
fn set_maximizable(&self, maximizable: bool) -> Result<()>
Updates the window’s native maximize button state.
§Platform-specific
- macOS: Disables the “zoom” button in the window titlebar, which is also used to enter fullscreen mode.
- Linux / iOS / Android: Unsupported.
Sourcefn set_minimizable(&self, minimizable: bool) -> Result<()>
fn set_minimizable(&self, minimizable: bool) -> Result<()>
Updates the window’s native minimize button state.
§Platform-specific
- Linux / iOS / Android: Unsupported.
Sourcefn set_closable(&self, closable: bool) -> Result<()>
fn set_closable(&self, closable: bool) -> Result<()>
Updates the window’s native close button state.
§Platform-specific
- Linux: “GTK+ will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible”
- iOS / Android: Unsupported.
Sourcefn unmaximize(&self) -> Result<()>
fn unmaximize(&self) -> Result<()>
Unmaximizes the window.
Sourcefn unminimize(&self) -> Result<()>
fn unminimize(&self) -> Result<()>
Unminimizes the window.
Sourcefn set_decorations(&self, decorations: bool) -> Result<()>
fn set_decorations(&self, decorations: bool) -> Result<()>
Updates the decorations flag.
Sourcefn set_shadow(&self, enable: bool) -> Result<()>
fn set_shadow(&self, enable: bool) -> Result<()>
Updates the shadow flag.
Sourcefn set_always_on_bottom(&self, always_on_bottom: bool) -> Result<()>
fn set_always_on_bottom(&self, always_on_bottom: bool) -> Result<()>
Updates the window alwaysOnBottom flag.
Sourcefn set_always_on_top(&self, always_on_top: bool) -> Result<()>
fn set_always_on_top(&self, always_on_top: bool) -> Result<()>
Updates the window alwaysOnTop flag.
Sourcefn set_visible_on_all_workspaces(
&self,
visible_on_all_workspaces: bool,
) -> Result<()>
fn set_visible_on_all_workspaces( &self, visible_on_all_workspaces: bool, ) -> Result<()>
Updates the window visibleOnAllWorkspaces flag.
Sourcefn set_content_protected(&self, protected: bool) -> Result<()>
fn set_content_protected(&self, protected: bool) -> Result<()>
Prevents the window contents from being captured by other apps.
Sourcefn set_size_constraints(&self, constraints: WindowSizeConstraints) -> Result<()>
fn set_size_constraints(&self, constraints: WindowSizeConstraints) -> Result<()>
Sets this window’s minimum inner width.
Sourcefn set_position(&self, position: Position) -> Result<()>
fn set_position(&self, position: Position) -> Result<()>
Updates the window position.
Sourcefn set_fullscreen(&self, fullscreen: bool) -> Result<()>
fn set_fullscreen(&self, fullscreen: bool) -> Result<()>
Updates the window fullscreen state.
Sourcefn set_skip_taskbar(&self, skip: bool) -> Result<()>
fn set_skip_taskbar(&self, skip: bool) -> Result<()>
Whether to hide the window icon from the taskbar or not.
Sourcefn set_cursor_grab(&self, grab: bool) -> Result<()>
fn set_cursor_grab(&self, grab: bool) -> Result<()>
Grabs the cursor, preventing it from leaving the window.
There’s no guarantee that the cursor will be hidden. You should hide it by yourself if you want so.
Sourcefn set_cursor_visible(&self, visible: bool) -> Result<()>
fn set_cursor_visible(&self, visible: bool) -> Result<()>
Modifies the cursor’s visibility.
If false
, this will hide the cursor. If true
, this will show the cursor.
fn set_cursor_icon(&self, icon: CursorIcon) -> Result<()>
Sourcefn set_cursor_position<Pos: Into<Position>>(&self, position: Pos) -> Result<()>
fn set_cursor_position<Pos: Into<Position>>(&self, position: Pos) -> Result<()>
Changes the position of the cursor in window coordinates.
Sourcefn set_ignore_cursor_events(&self, ignore: bool) -> Result<()>
fn set_ignore_cursor_events(&self, ignore: bool) -> Result<()>
Ignores the window cursor events.
Sourcefn start_dragging(&self) -> Result<()>
fn start_dragging(&self) -> Result<()>
Starts dragging the window.
Sourcefn start_resize_dragging(&self, direction: ResizeDirection) -> Result<()>
fn start_resize_dragging(&self, direction: ResizeDirection) -> Result<()>
Starts resize-dragging the window.
Sourcefn set_progress_bar(&self, progress_state: ProgressBarState) -> Result<()>
fn set_progress_bar(&self, progress_state: ProgressBarState) -> Result<()>
Sets the taskbar progress state.
§Platform-specific
- Linux / macOS: Progress bar is app-wide and not specific to this window. Only supported desktop environments with
libunity
(e.g. GNOME). - iOS / Android: Unsupported.
Sourcefn set_title_bar_style(&self, style: TitleBarStyle) -> Result<()>
fn set_title_bar_style(&self, style: TitleBarStyle) -> Result<()>
Sets the title bar style. Available on macOS only.
§Platform-specific
- Linux / Windows / iOS / Android: Unsupported.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.