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§
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
Sourcefn visibility(&self) -> WindowVisibility
fn visibility(&self) -> WindowVisibility
The current WindowVisibility. Read once when the window is created;
afterwards changes arrive through Self::on_visibility_change.
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)>)
Sourcefn on_visibility_change(&self, callback: Box<dyn FnMut(WindowVisibility)>)
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.
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()>)
Sourcefn on_display_changed(&self, callback: Box<dyn FnMut()>)
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.
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§
Sourcefn visual_viewport_bounds(&self) -> Bounds<Pixels>
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.
Sourcefn on_visual_viewport_changed(&self, _callback: Box<dyn FnMut()>)
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.
Sourcefn prepare_frame(&self) -> bool
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.
Sourcefn set_text_input_configuration(
&mut self,
_configuration: TextInputConfiguration,
)
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.
Sourcefn request_attention(&self)
fn request_attention(&self)
Requests that the operating system draw attention to this window.
Sourcefn debug_state(&self) -> Value
fn debug_state(&self) -> Value
Platform-specific diagnostic state, for App::debug_state.
fn frame_waker(&self) -> Option<Rc<dyn Fn()>>
Sourceunsafe fn attach_native_view(
&self,
_id: NativeViewId,
_view: NonNull<c_void>,
) -> Option<Box<dyn Any>>
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.
Sourcefn set_focused_native_view(&self, _id: Option<NativeViewId>)
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.
Sourcefn on_hit_test_native_view(
&self,
_callback: Box<dyn FnMut(Point<Pixels>) -> Option<NativeViewId>>,
)
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.
Sourcefn on_native_view_focused(&self, _callback: Box<dyn FnMut(NativeViewId)>)
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.
Sourcefn on_key_down_before_native_view(
&self,
_callback: Box<dyn FnMut(KeyDownEvent) -> bool>,
)
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.
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 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>)
Sourcefn insets(&self) -> WindowInsets
fn insets(&self) -> WindowInsets
The regions of this window currently obscured or reserved by the system. Zero on platforms without such regions.
Sourcefn on_insets_changed(&self, _callback: Box<dyn FnMut(WindowInsets)>)
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.
Sourcefn set_back_handler(&self, _callback: Box<dyn FnMut()>)
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).
Sourcefn set_back_enabled(&self, _enabled: bool)
fn set_back_enabled(&self, _enabled: bool)
Declares whether the application would currently handle the system back action (e.g. navigation depth > 0).
Sourcefn show_soft_keyboard(&self)
fn show_soft_keyboard(&self)
Requests that the soft keyboard be shown.
Sourcefn hide_soft_keyboard(&self)
fn hide_soft_keyboard(&self)
Requests that the soft keyboard be hidden.
Sourcefn text_input_state_changed(&self, _change: TextInputStateChange)
fn text_input_state_changed(&self, _change: TextInputStateChange)
Inform the operating system that the text input state has changed
fn play_system_bell(&self)
Sourcefn a11y_init(&self, _callbacks: A11yCallbacks)
fn a11y_init(&self, _callbacks: A11yCallbacks)
Initialize the accessibility adapter with callbacks.
Sourcefn a11y_tree_update(&self, _tree_update: TreeUpdate)
fn a11y_tree_update(&self, _tree_update: TreeUpdate)
Provide a TreeUpdate to the accessibility adapter.
Sourcefn a11y_update_window_bounds(&self)
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".