pub struct HarmonyPlatform { /* private fields */ }Expand description
Unified HarmonyOS / OpenHarmony platform backend bridging ArkUI XComponent, OHNativeWindow, EGL/GLES3/Vulkan, and NAPI.
Implementations§
Source§impl HarmonyPlatform
ArkUI XComponent binding, avoidArea safe-area, foldable transition, touch/key/IME, and UIAbility lifecycle hooks for HarmonyPlatform.
impl HarmonyPlatform
ArkUI XComponent binding, avoidArea safe-area, foldable transition, touch/key/IME, and UIAbility lifecycle hooks for HarmonyPlatform.
Sourcepub fn for_device_type(device_type: HarmonyDeviceType) -> Self
pub fn for_device_type(device_type: HarmonyDeviceType) -> Self
Sourcepub fn primary_window_id(&self) -> Option<WindowId>
pub fn primary_window_id(&self) -> Option<WindowId>
Sourcepub fn attach_xcomponent(
&mut self,
native_window: usize,
xcomponent: usize,
phys_width: u32,
phys_height: u32,
)
pub fn attach_xcomponent( &mut self, native_window: usize, xcomponent: usize, phys_width: u32, phys_height: u32, )
Attaches live ArkUI OHNativeWindow* and OH_NativeXComponent* handles received from OnSurfaceCreatedCB.
§Arguments
&Self- Mutable HarmonyOS platform.usize- RawOHNativeWindow*pointer.usize- RawOH_NativeXComponent*pointer.u32- Physical surface width in pixels.u32- Physical surface height in pixels.
Sourcepub fn detach_xcomponent(&mut self)
pub fn detach_xcomponent(&mut self)
Detaches ArkUI OHNativeWindow* safely on OnSurfaceDestroyedCB and cancels dangling touches.
§Arguments
&Self- Mutable HarmonyOS platform.
Sourcepub fn update_avoid_area(&mut self, avoid: HarmonyAvoidArea)
pub fn update_avoid_area(&mut self, avoid: HarmonyAvoidArea)
Updates HarmonyOS window.AvoidArea insets and emits SafeAreaChanged plus KeyboardVisibilityChanged.
§Arguments
&Self- Mutable HarmonyOS platform.HarmonyAvoidArea- Physical-pixel avoid area from@ohos.window.
Sourcepub fn handle_lifecycle_hook(
&mut self,
hook: HarmonyLifecycleHook,
) -> Vec<WindowEvent>
pub fn handle_lifecycle_hook( &mut self, hook: HarmonyLifecycleHook, ) -> Vec<WindowEvent>
Translates a Stage-Model HarmonyLifecycleHook into canonical EUV SystemEvents and Freeze/Resume/Destroy transitions.
§Arguments
&Self- Mutable HarmonyOS platform.HarmonyLifecycleHook- Native ArkTS UIAbility / WindowStage callback payload.
§Returns
Vec<WindowEvent>- Normalized events also enqueued forpoll_events().
Sourcepub fn handle_touch_event(
&mut self,
touch_type: i32,
raw_id: i32,
phys_x: f32,
phys_y: f32,
) -> Vec<WindowEvent>
pub fn handle_touch_event( &mut self, touch_type: i32, raw_id: i32, phys_x: f32, phys_y: f32, ) -> Vec<WindowEvent>
Translates an OpenHarmony OH_NativeXComponent touch contact action into normalized EUV pointer events.
§Arguments
&Self- Mutable HarmonyOS platform.i32- OpenHarmony touch action (HARMONY_TOUCH_DOWN..HARMONY_TOUCH_CANCEL).i32- Raw contact identifier.f32- Component-local physical X coordinate.f32- Component-local physical Y coordinate.
§Returns
Vec<WindowEvent>- Normalized pointer events.
Sourcepub fn handle_key_event(
&mut self,
ohos_code: i32,
down: bool,
) -> Option<WindowEvent>
pub fn handle_key_event( &mut self, ohos_code: i32, down: bool, ) -> Option<WindowEvent>
Sourcepub fn handle_ime_commit(&mut self, text: String)
pub fn handle_ime_commit(&mut self, text: String)
Dispatches committed HarmonyOS IME UTF-8 text into WindowEvent::TextInput.
§Arguments
&Self- Mutable HarmonyOS platform.String- Committed UTF-8 text.
Source§impl HarmonyPlatform
impl HarmonyPlatform
pub fn get_profile(&self) -> HarmonyDeviceProfile
pub fn get_mut_profile(&mut self) -> &mut HarmonyDeviceProfile
pub fn set_profile(&mut self, val: HarmonyDeviceProfile) -> &mut Self
pub fn get_fold_state(&self) -> HarmonyFoldState
pub fn get_mut_fold_state(&mut self) -> &mut HarmonyFoldState
pub fn set_fold_state(&mut self, val: HarmonyFoldState) -> &mut Self
pub fn get_attached_native_window(&self) -> usize
pub fn get_mut_attached_native_window(&mut self) -> &mut usize
pub fn set_attached_native_window(&mut self, val: usize) -> &mut Self
pub fn get_attached_xcomponent(&self) -> usize
pub fn get_mut_attached_xcomponent(&mut self) -> &mut usize
pub fn set_attached_xcomponent(&mut self, val: usize) -> &mut Self
pub fn get_safe_area(&self) -> SafeAreaInsets
pub fn get_mut_safe_area(&mut self) -> &mut SafeAreaInsets
pub fn set_safe_area(&mut self, val: SafeAreaInsets) -> &mut Self
pub fn get_lifecycle(&self) -> &MobileSessionLifecycle
pub fn get_mut_lifecycle(&mut self) -> &mut MobileSessionLifecycle
pub fn set_lifecycle(&mut self, val: MobileSessionLifecycle) -> &mut Self
pub fn get_mut_primary_window(&mut self) -> &mut Option<WindowId>
pub fn set_primary_window(&mut self, val: Option<WindowId>) -> &mut Self
pub fn get_windows(&self) -> &HashMap<WindowId, HarmonyWindowRecord>
pub fn get_mut_windows(&mut self) -> &mut HashMap<WindowId, HarmonyWindowRecord>
pub fn set_windows( &mut self, val: HashMap<WindowId, HarmonyWindowRecord>, ) -> &mut Self
pub fn get_pending_events(&self) -> &Vec<WindowEvent>
pub fn get_mut_pending_events(&mut self) -> &mut Vec<WindowEvent>
pub fn set_pending_events(&mut self, val: Vec<WindowEvent>) -> &mut Self
pub fn get_mut_clipboard(&mut self) -> &mut Option<String>
pub fn set_clipboard(&mut self, val: Option<String>) -> &mut Self
pub fn get_storage(&self) -> &HashMap<String, String>
pub fn get_mut_storage(&mut self) -> &mut HashMap<String, String>
pub fn set_storage(&mut self, val: HashMap<String, String>) -> &mut Self
pub fn get_route_stack(&self) -> &Vec<String>
pub fn get_mut_route_stack(&mut self) -> &mut Vec<String>
pub fn set_route_stack(&mut self, val: Vec<String>) -> &mut Self
pub fn get_theme(&self) -> ThemeMode
pub fn get_mut_theme(&mut self) -> &mut ThemeMode
pub fn set_theme(&mut self, val: ThemeMode) -> &mut Self
pub fn get_pump_paused(&self) -> bool
pub fn get_mut_pump_paused(&mut self) -> &mut bool
pub fn set_pump_paused(&mut self, val: bool) -> &mut Self
Trait Implementations§
Source§impl Clone for HarmonyPlatform
impl Clone for HarmonyPlatform
Source§impl Debug for HarmonyPlatform
impl Debug for HarmonyPlatform
Source§impl Default for HarmonyPlatform
Default HarmonyPlatform configured for HarmonyDeviceType::Phone.
impl Default for HarmonyPlatform
Default HarmonyPlatform configured for HarmonyDeviceType::Phone.
Source§impl PlatformBackend for HarmonyPlatform
PlatformBackend implementation for HarmonyPlatform.
impl PlatformBackend for HarmonyPlatform
PlatformBackend implementation for HarmonyPlatform.
Source§fn kind(&self) -> PlatformKind
fn kind(&self) -> PlatformKind
Source§fn capabilities(&self) -> PlatformCapabilities
fn capabilities(&self) -> PlatformCapabilities
Source§fn create_window(
&mut self,
config: &WindowConfig,
) -> Result<WindowState, PlatformError>
fn create_window( &mut self, config: &WindowConfig, ) -> Result<WindowState, PlatformError>
Source§fn window_state(&self, id: WindowId) -> Option<WindowState>
fn window_state(&self, id: WindowId) -> Option<WindowState>
Source§fn raw_window_handle(&self, id: WindowId) -> RawWindowHandle
fn raw_window_handle(&self, id: WindowId) -> RawWindowHandle
Source§fn poll_events(&mut self) -> Vec<WindowEvent>
fn poll_events(&mut self) -> Vec<WindowEvent>
Source§fn set_frame_pump_paused(&mut self, paused: bool)
fn set_frame_pump_paused(&mut self, paused: bool)
Pauses or resumes the HarmonyOS OH_NativeVSync frame pump flag.
§Arguments
&Self- Mutable HarmonyOS platform.bool-trueto pause for background freeze.
Source§fn is_frame_pump_paused(&self) -> bool
fn is_frame_pump_paused(&self) -> bool
Source§fn present_framebuffer(
&mut self,
id: WindowId,
framebuffer: &Framebuffer,
) -> Result<(), PlatformError>
fn present_framebuffer( &mut self, id: WindowId, framebuffer: &Framebuffer, ) -> Result<(), PlatformError>
Source§fn read_clipboard(&self) -> Option<String>
fn read_clipboard(&self) -> Option<String>
Source§fn write_clipboard(&mut self, text: &str) -> Result<(), PlatformError>
fn write_clipboard(&mut self, text: &str) -> Result<(), PlatformError>
Source§fn system_theme(&self) -> ThemeMode
fn system_theme(&self) -> ThemeMode
Source§fn display_refresh_rate_hz(&self) -> f32
fn display_refresh_rate_hz(&self) -> f32
Source§fn wait_for_events(&mut self) -> Vec<WindowEvent>
fn wait_for_events(&mut self) -> Vec<WindowEvent>
Source§fn present_framebuffer_region(
&mut self,
id: WindowId,
framebuffer: &Framebuffer,
_damage: DamageRegion,
) -> Result<(), PlatformError>
fn present_framebuffer_region( &mut self, id: WindowId, framebuffer: &Framebuffer, _damage: DamageRegion, ) -> Result<(), PlatformError>
Framebuffer when supported by the backend. Read moreSource§impl PlatformHostAdapter for HarmonyPlatform
PlatformHostAdapter implementation for HarmonyPlatform.
impl PlatformHostAdapter for HarmonyPlatform
PlatformHostAdapter implementation for HarmonyPlatform.
Source§fn device_form_factor(&self) -> DeviceFormFactor
fn device_form_factor(&self) -> DeviceFormFactor
Source§impl PlatformLifecycleBridge for HarmonyPlatform
PlatformLifecycleBridge implementation for HarmonyPlatform.
impl PlatformLifecycleBridge for HarmonyPlatform
PlatformLifecycleBridge implementation for HarmonyPlatform.
Source§fn freeze_surface(&mut self) -> Vec<WindowEvent>
fn freeze_surface(&mut self) -> Vec<WindowEvent>
Source§fn resume_surface(&mut self) -> Vec<WindowEvent>
fn resume_surface(&mut self) -> Vec<WindowEvent>
Source§fn destroy_surface(&mut self) -> Vec<WindowEvent>
fn destroy_surface(&mut self) -> Vec<WindowEvent>
Source§impl PlatformStorage for HarmonyPlatform
PlatformStorage implementation for HarmonyPlatform.
impl PlatformStorage for HarmonyPlatform
PlatformStorage implementation for HarmonyPlatform.
Source§fn storage_set(&mut self, key: &str, value: &str) -> Result<(), PlatformError>
fn storage_set(&mut self, key: &str, value: &str) -> Result<(), PlatformError>
Source§fn storage_remove(&mut self, key: &str) -> Result<(), PlatformError>
fn storage_remove(&mut self, key: &str) -> Result<(), PlatformError>
Source§fn storage_clear(&mut self) -> Result<(), PlatformError>
fn storage_clear(&mut self) -> Result<(), PlatformError>
Source§impl WindowController for HarmonyPlatform
WindowController implementation for HarmonyPlatform.
impl WindowController for HarmonyPlatform
WindowController implementation for HarmonyPlatform.