Skip to content

Commit

Permalink
implement Android
Browse files Browse the repository at this point in the history
  • Loading branch information
jgcodes2020 committed Oct 21, 2024
1 parent 5fa22f6 commit b472c10
Showing 1 changed file with 41 additions and 38 deletions.
79 changes: 41 additions & 38 deletions src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::platform::pump_events::PumpStatus;
use crate::window::{
self, CursorGrabMode, CustomCursor, CustomCursorSource, Fullscreen, ImePurpose,
ResizeDirection, Theme, Window as CoreWindow, WindowAttributes, WindowButtons, WindowId,
WindowLevel,
WindowLevel, Surface as CoreSurface
};

mod keycodes;
Expand Down Expand Up @@ -804,7 +804,7 @@ impl rwh_06::HasWindowHandle for Window {
}
}

impl CoreWindow for Window {
impl CoreSurface for Window {
fn id(&self) -> WindowId {
GLOBAL_WINDOW
}
Expand All @@ -831,6 +831,45 @@ impl CoreWindow for Window {

fn pre_present_notify(&self) {}

fn surface_size(&self) -> PhysicalSize<u32> {
self.outer_size()
}

fn request_surface_size(&self, _size: Size) -> Option<PhysicalSize<u32>> {
Some(self.surface_size())
}

fn set_transparent(&self, _transparent: bool) {}

fn set_cursor(&self, _: Cursor) {}

fn set_cursor_position(&self, _: Position) -> Result<(), RequestError> {
Err(NotSupportedError::new("set_cursor_position is not supported").into())
}

fn set_cursor_grab(&self, _: CursorGrabMode) -> Result<(), RequestError> {
Err(NotSupportedError::new("set_cursor_grab is not supported").into())
}

fn set_cursor_visible(&self, _: bool) {}

fn set_cursor_hittest(&self, _hittest: bool) -> Result<(), RequestError> {
Err(NotSupportedError::new("set_cursor_hittest is not supported").into())
}

#[cfg(feature = "rwh_06")]
fn rwh_06_display_handle(&self) -> &dyn rwh_06::HasDisplayHandle {
self
}

#[cfg(feature = "rwh_06")]
fn rwh_06_window_handle(&self) -> &dyn rwh_06::HasWindowHandle {
self
}
}

impl CoreWindow for Window {

fn inner_position(&self) -> Result<PhysicalPosition<i32>, RequestError> {
Err(NotSupportedError::new("inner_position is not supported").into())
}
Expand All @@ -843,14 +882,6 @@ impl CoreWindow for Window {
// no effect
}

fn surface_size(&self) -> PhysicalSize<u32> {
self.outer_size()
}

fn request_surface_size(&self, _size: Size) -> Option<PhysicalSize<u32>> {
Some(self.surface_size())
}

fn outer_size(&self) -> PhysicalSize<u32> {
screen_size(&self.app)
}
Expand All @@ -867,8 +898,6 @@ impl CoreWindow for Window {

fn set_title(&self, _title: &str) {}

fn set_transparent(&self, _transparent: bool) {}

fn set_blur(&self, _blur: bool) {}

fn set_visible(&self, _visibility: bool) {}
Expand Down Expand Up @@ -929,18 +958,6 @@ impl CoreWindow for Window {

fn request_user_attention(&self, _request_type: Option<window::UserAttentionType>) {}

fn set_cursor(&self, _: Cursor) {}

fn set_cursor_position(&self, _: Position) -> Result<(), RequestError> {
Err(NotSupportedError::new("set_cursor_position is not supported").into())
}

fn set_cursor_grab(&self, _: CursorGrabMode) -> Result<(), RequestError> {
Err(NotSupportedError::new("set_cursor_grab is not supported").into())
}

fn set_cursor_visible(&self, _: bool) {}

fn drag_window(&self) -> Result<(), RequestError> {
Err(NotSupportedError::new("drag_window is not supported").into())
}
Expand All @@ -952,10 +969,6 @@ impl CoreWindow for Window {
#[inline]
fn show_window_menu(&self, _position: Position) {}

fn set_cursor_hittest(&self, _hittest: bool) -> Result<(), RequestError> {
Err(NotSupportedError::new("set_cursor_hittest is not supported").into())
}

fn set_theme(&self, _theme: Option<Theme>) {}

fn theme(&self) -> Option<Theme> {
Expand All @@ -973,16 +986,6 @@ impl CoreWindow for Window {
}

fn reset_dead_keys(&self) {}

#[cfg(feature = "rwh_06")]
fn rwh_06_display_handle(&self) -> &dyn rwh_06::HasDisplayHandle {
self
}

#[cfg(feature = "rwh_06")]
fn rwh_06_window_handle(&self) -> &dyn rwh_06::HasWindowHandle {
self
}
}

#[derive(Default, Clone, Debug)]
Expand Down

0 comments on commit b472c10

Please sign in to comment.