Skip to main content

PlatformWindow

Trait PlatformWindow 

Source
pub trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
Show 103 methods // Required methods fn bounds(&self) -> Bounds<Pixels>; fn is_maximized(&self) -> bool; fn window_bounds(&self) -> WindowBounds; fn content_size(&self) -> Size<Pixels>; fn resize(&mut self, size: Size<Pixels>); fn scale_factor(&self) -> f32; fn appearance(&self) -> WindowAppearance; fn display(&self) -> Option<Rc<dyn PlatformDisplay>>; fn mouse_position(&self) -> Point<Pixels>; fn modifiers(&self) -> Modifiers; fn capslock(&self) -> Capslock; fn set_input_handler(&mut self, input_handler: PlatformInputHandler); fn take_input_handler(&mut self) -> Option<PlatformInputHandler>; fn prompt( &self, level: PromptLevel, msg: &str, detail: Option<&str>, answers: &[PromptButton], ) -> Option<Receiver<usize>>; fn activate(&self); fn is_active(&self) -> bool; fn visibility(&self) -> WindowVisibility; fn is_hovered(&self) -> bool; fn background_appearance(&self) -> WindowBackgroundAppearance; fn set_title(&mut self, title: &str); fn set_background_appearance( &self, background_appearance: WindowBackgroundAppearance, ); fn minimize(&self); fn zoom(&self); fn toggle_fullscreen(&self); fn is_fullscreen(&self) -> bool; fn on_request_frame(&self, callback: Box<dyn FnMut(RequestFrameOptions)>); fn on_input( &self, callback: Box<dyn FnMut(PlatformInput) -> DispatchEventResult>, ); fn on_active_status_change(&self, callback: Box<dyn FnMut(bool)>); fn on_visibility_change(&self, callback: Box<dyn FnMut(WindowVisibility)>); fn on_hover_status_change(&self, callback: Box<dyn FnMut(bool)>); fn on_resize(&self, callback: Box<dyn FnMut(Size<Pixels>, f32)>); fn on_moved(&self, callback: Box<dyn FnMut()>); fn on_display_changed(&self, callback: Box<dyn FnMut()>); fn on_should_close(&self, callback: Box<dyn FnMut() -> bool>); fn on_hit_test_window_control( &self, callback: Box<dyn FnMut() -> Option<WindowControlArea>>, ); fn on_close(&self, callback: Box<dyn FnOnce()>); fn on_appearance_changed(&self, callback: Box<dyn FnMut()>); fn draw(&self, scene: &Scene); fn sprite_atlas(&self) -> Arc<dyn PlatformAtlas> ⓘ; fn is_subpixel_rendering_supported(&self) -> bool; fn gpu_specs(&self) -> Option<GpuSpecs>; fn update_ime_position(&self, _bounds: Bounds<Pixels>); // Provided methods fn visual_viewport_bounds(&self) -> Bounds<Pixels> { ... } fn on_visual_viewport_changed(&self, _callback: Box<dyn FnMut()>) { ... } fn prepare_frame(&self) -> bool { ... } fn set_text_input_configuration( &mut self, _configuration: TextInputConfiguration, ) { ... } fn request_attention(&self) { ... } fn debug_state(&self) -> Value { ... } fn frame_waker(&self) -> Option<Rc<dyn Fn()>> { ... } unsafe fn attach_native_view( &self, _id: NativeViewId, _view: NonNull<c_void>, ) -> Option<Box<dyn Any>> { ... } fn set_focused_native_view(&self, _id: Option<NativeViewId>) { ... } fn on_hit_test_native_view( &self, _callback: Box<dyn FnMut(Point<Pixels>) -> Option<NativeViewId>>, ) { ... } fn on_native_view_focused(&self, _callback: Box<dyn FnMut(NativeViewId)>) { ... } fn on_key_down_before_native_view( &self, _callback: Box<dyn FnMut(KeyDownEvent) -> bool>, ) { ... } fn on_button_layout_changed(&self, _callback: Box<dyn FnMut()>) { ... } fn schedule_frame(&self) { ... } fn get_title(&self) -> String { ... } fn tabbed_windows(&self) -> Option<Vec<SystemWindowTab>> { ... } fn tab_bar_visible(&self) -> bool { ... } fn set_edited(&mut self, _edited: bool) { ... } fn set_document_path(&self, _path: Option<&Path>) { ... } fn toggle_simple_fullscreen(&self) { ... } fn is_simple_fullscreen(&self) -> bool { ... } fn show_character_palette(&self) { ... } fn titlebar_double_click(&self, _is_resizable: bool, _is_minimizable: bool) { ... } fn on_move_tab_to_new_window(&self, _callback: Box<dyn FnMut()>) { ... } fn on_merge_all_windows(&self, _callback: Box<dyn FnMut()>) { ... } fn on_select_previous_tab(&self, _callback: Box<dyn FnMut()>) { ... } fn on_select_next_tab(&self, _callback: Box<dyn FnMut()>) { ... } fn on_toggle_tab_bar(&self, _callback: Box<dyn FnMut()>) { ... } fn merge_all_windows(&self) { ... } fn move_tab_to_new_window(&self) { ... } fn toggle_window_tab_overview(&self) { ... } fn set_tabbing_identifier(&self, _identifier: Option<String>) { ... } fn native_window_state(&self) -> Option<Vec<u8>> { ... } fn restore_native_window_state(&self, _state: &[u8]) { ... } fn inner_window_bounds(&self) -> WindowBounds { ... } fn request_decorations(&self, _decorations: WindowDecorations) { ... } fn show_window_menu(&self, _position: Point<Pixels>) { ... } fn start_window_move(&self) { ... } fn can_start_external_drag(&self) -> bool { ... } fn start_external_drag(&self, _payload: &ExternalDragPayload) -> bool { ... } fn start_window_resize(&self, _edge: ResizeEdge) { ... } fn set_exclusive_zone(&self, _zone: Pixels) { ... } fn set_exclusive_edge(&self, _edge: Anchor) { ... } fn set_input_region(&self, _region: Option<&[Bounds<Pixels>]>) { ... } fn window_decorations(&self) -> Decorations { ... } fn set_app_id(&mut self, _app_id: &str) { ... } fn map_window(&mut self) -> Result<()> { ... } fn window_controls(&self) -> WindowControls { ... } fn set_client_inset(&self, _inset: Pixels) { ... } fn set_client_corner_radii(&self, _radii: Corners<Pixels>) { ... } fn insets(&self) -> WindowInsets { ... } fn on_insets_changed(&self, _callback: Box<dyn FnMut(WindowInsets)>) { ... } fn set_back_handler(&self, _callback: Box<dyn FnMut()>) { ... } fn set_back_enabled(&self, _enabled: bool) { ... } fn show_soft_keyboard(&self) { ... } fn hide_soft_keyboard(&self) { ... } fn text_input_state_changed(&self, _change: TextInputStateChange) { ... } fn play_system_bell(&self) { ... } fn a11y_init(&self, _callbacks: A11yCallbacks) { ... } fn a11y_tree_update(&self, _tree_update: TreeUpdate) { ... } fn a11y_update_window_bounds(&self) { ... }
}

Required Methods§

Source

fn bounds(&self) -> Bounds<Pixels>

Source

fn is_maximized(&self) -> bool

Source

fn window_bounds(&self) -> WindowBounds

Source

fn content_size(&self) -> Size<Pixels>

Source

fn resize(&mut self, size: Size<Pixels>)

Source

fn scale_factor(&self) -> f32

Source

fn appearance(&self) -> WindowAppearance

Source

fn display(&self) -> Option<Rc<dyn PlatformDisplay>>

Source

fn mouse_position(&self) -> Point<Pixels>

Source

fn modifiers(&self) -> Modifiers

Source

fn capslock(&self) -> Capslock

Source

fn set_input_handler(&mut self, input_handler: PlatformInputHandler)

Source

fn take_input_handler(&mut self) -> Option<PlatformInputHandler>

Source

fn prompt( &self, level: PromptLevel, msg: &str, detail: Option<&str>, answers: &[PromptButton], ) -> Option<Receiver<usize>>

Source

fn activate(&self)

Source

fn is_active(&self) -> bool

Source

fn visibility(&self) -> WindowVisibility

The current WindowVisibility. Read once when the window is created; afterwards changes arrive through Self::on_visibility_change.

Source

fn is_hovered(&self) -> bool

Source

fn background_appearance(&self) -> WindowBackgroundAppearance

Source

fn set_title(&mut self, title: &str)

Source

fn set_background_appearance( &self, background_appearance: WindowBackgroundAppearance, )

Source

fn minimize(&self)

Source

fn zoom(&self)

Source

fn toggle_fullscreen(&self)

Source

fn is_fullscreen(&self) -> bool

Source

fn on_request_frame(&self, callback: Box<dyn FnMut(RequestFrameOptions)>)

Source

fn on_input( &self, callback: Box<dyn FnMut(PlatformInput) -> DispatchEventResult>, )

Source

fn on_active_status_change(&self, callback: Box<dyn FnMut(bool)>)

Source

fn on_visibility_change(&self, callback: Box<dyn FnMut(WindowVisibility)>)

Registers the callback invoked when Self::visibility changes. Only transitions are reported; the callback runs on the main thread outside of any window update.

Source

fn on_hover_status_change(&self, callback: Box<dyn FnMut(bool)>)

Source

fn on_resize(&self, callback: Box<dyn FnMut(Size<Pixels>, f32)>)

Source

fn on_moved(&self, callback: Box<dyn FnMut()>)

Source

fn on_display_changed(&self, callback: Box<dyn FnMut()>)

Registers the callback invoked when the window moves to another display. Calls may be spurious. The callback runs on the main thread outside of any window update.

Source

fn on_should_close(&self, callback: Box<dyn FnMut() -> bool>)

Source

fn on_hit_test_window_control( &self, callback: Box<dyn FnMut() -> Option<WindowControlArea>>, )

Source

fn on_close(&self, callback: Box<dyn FnOnce()>)

Source

fn on_appearance_changed(&self, callback: Box<dyn FnMut()>)

Source

fn draw(&self, scene: &Scene)

Source

fn sprite_atlas(&self) -> Arc<dyn PlatformAtlas> ⓘ

Source

fn is_subpixel_rendering_supported(&self) -> bool

Source

fn gpu_specs(&self) -> Option<GpuSpecs>

Source

fn update_ime_position(&self, _bounds: Bounds<Pixels>)

Provided Methods§

Source

fn visual_viewport_bounds(&self) -> Bounds<Pixels>

Returns the visible viewport in logical pixels relative to the content origin.

This may be smaller or offset when a keyboard or zoom obscures content; it must not change the full layout size returned by content_size. Implementations should return a frame snapshot, not query platform layout here.

Source

fn on_visual_viewport_changed(&self, _callback: Box<dyn FnMut()>)

Registers a callback when visible geometry may have changed.

This requests a frame; backends can sample the new viewport and safe-area geometry in prepare_frame rather than updating it inside the callback.

Source

fn prepare_frame(&self) -> bool

Samples platform geometry before a draw, returning whether view caches must be invalidated.

Geometry getters must remain consistent throughout the ensuing draw. Do not invoke callbacks here: GPUI is already updating this window.

Source

fn set_text_input_configuration( &mut self, _configuration: TextInputConfiguration, )

Apply the focused text region’s TextInputConfiguration to the platform’s text input session (e.g. attributes of the hidden editable element on web). Called only when the configuration changes, because reconfiguring a live input session can restart the IME connection.

Source

fn request_attention(&self)

Requests that the operating system draw attention to this window.

Source

fn debug_state(&self) -> Value

Platform-specific diagnostic state, for App::debug_state.

Source

fn frame_waker(&self) -> Option<Rc<dyn Fn()>>

Source

unsafe fn attach_native_view( &self, _id: NativeViewId, _view: NonNull<c_void>, ) -> Option<Box<dyn Any>>

Adds a platform view beneath the window’s rendered content, hidden until a drawn scene contains a PaintNativeView for it. Dropping the returned value removes the view from the window. Returns None when the platform cannot composite native views.

§Safety

view must point to a live view of the kind this platform embeds, which is not in another view hierarchy.

Source

fn set_focused_native_view(&self, _id: Option<NativeViewId>)

Gives keyboard input to the native view, or back to the window’s own content for None.

Source

fn on_hit_test_native_view( &self, _callback: Box<dyn FnMut(Point<Pixels>) -> Option<NativeViewId>>, )

Registers the callback that decides whether a mouse event at a position belongs to a native view instead of the window’s content.

Source

fn on_native_view_focused(&self, _callback: Box<dyn FnMut(NativeViewId)>)

Registers the callback invoked when the user moves keyboard input to a native view through the platform, such as by clicking in it.

Source

fn on_key_down_before_native_view( &self, _callback: Box<dyn FnMut(KeyDownEvent) -> bool>, )

Registers the callback offered each key press before the native view that has keyboard input, which returns whether it used the key.

The native view receives the keys it doesn’t use, and the ones the view doesn’t use either arrive afterwards as ordinary input.

Source

fn on_button_layout_changed(&self, _callback: Box<dyn FnMut()>)

Source

fn schedule_frame(&self)

Source

fn get_title(&self) -> String

Source

fn tabbed_windows(&self) -> Option<Vec<SystemWindowTab>>

Source

fn tab_bar_visible(&self) -> bool

Source

fn set_edited(&mut self, _edited: bool)

Source

fn set_document_path(&self, _path: Option<&Path>)

Source

fn toggle_simple_fullscreen(&self)

Source

fn is_simple_fullscreen(&self) -> bool

Source

fn show_character_palette(&self)

Source

fn titlebar_double_click(&self, _is_resizable: bool, _is_minimizable: bool)

Source

fn on_move_tab_to_new_window(&self, _callback: Box<dyn FnMut()>)

Source

fn on_merge_all_windows(&self, _callback: Box<dyn FnMut()>)

Source

fn on_select_previous_tab(&self, _callback: Box<dyn FnMut()>)

Source

fn on_select_next_tab(&self, _callback: Box<dyn FnMut()>)

Source

fn on_toggle_tab_bar(&self, _callback: Box<dyn FnMut()>)

Source

fn merge_all_windows(&self)

Source

fn move_tab_to_new_window(&self)

Source

fn toggle_window_tab_overview(&self)

Source

fn set_tabbing_identifier(&self, _identifier: Option<String>)

Source

fn native_window_state(&self) -> Option<Vec<u8>>

Source

fn restore_native_window_state(&self, _state: &[u8])

Source

fn inner_window_bounds(&self) -> WindowBounds

Source

fn request_decorations(&self, _decorations: WindowDecorations)

Source

fn show_window_menu(&self, _position: Point<Pixels>)

Source

fn start_window_move(&self)

Source

fn can_start_external_drag(&self) -> bool

Source

fn start_external_drag(&self, _payload: &ExternalDragPayload) -> bool

Source

fn start_window_resize(&self, _edge: ResizeEdge)

Source

fn set_exclusive_zone(&self, _zone: Pixels)

Source

fn set_exclusive_edge(&self, _edge: Anchor)

Source

fn set_input_region(&self, _region: Option<&[Bounds<Pixels>]>)

Source

fn window_decorations(&self) -> Decorations

Source

fn set_app_id(&mut self, _app_id: &str)

Source

fn map_window(&mut self) -> Result<()>

Source

fn window_controls(&self) -> WindowControls

Source

fn set_client_inset(&self, _inset: Pixels)

Source

fn set_client_corner_radii(&self, _radii: Corners<Pixels>)

Source

fn insets(&self) -> WindowInsets

The regions of this window currently obscured or reserved by the system. Zero on platforms without such regions.

Source

fn on_insets_changed(&self, _callback: Box<dyn FnMut(WindowInsets)>)

Registers a callback invoked whenever Self::insets change.

Contract: fires continuously during animated transitions (Android WindowInsetsAnimation progress; on iOS the platform interpolates the keyboard animation curve on frame ticks) and is exact at rest.

Source

fn set_back_handler(&self, _callback: Box<dyn FnMut()>)

Sets the handler for the system back action (Android back button/gesture; no source on iOS or desktop).

Source

fn set_back_enabled(&self, _enabled: bool)

Declares whether the application would currently handle the system back action (e.g. navigation depth > 0).

Source

fn show_soft_keyboard(&self)

Requests that the soft keyboard be shown.

Source

fn hide_soft_keyboard(&self)

Requests that the soft keyboard be hidden.

Source

fn text_input_state_changed(&self, _change: TextInputStateChange)

Inform the operating system that the text input state has changed

Source

fn play_system_bell(&self)

Source

fn a11y_init(&self, _callbacks: A11yCallbacks)

Initialize the accessibility adapter with callbacks.

Source

fn a11y_tree_update(&self, _tree_update: TreeUpdate)

Provide a TreeUpdate to the accessibility adapter.

Source

fn a11y_update_window_bounds(&self)

Inform the adapter of updated window bounds.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§