From e2f4ac6643d4b27ec1cf0ca813906a533cfc3bd0 Mon Sep 17 00:00:00 2001 From: Michal Hornicky Date: Sat, 9 Jan 2021 21:30:26 +0100 Subject: [PATCH] Android: add request_redraw based on ndk_glue --- CHANGELOG.md | 2 +- src/platform_impl/android/mod.rs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea0df5a7b0..d67999f78d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # Unreleased - +- On Android, implemented `request_redraw`, fixing issue where iced would not render properly - On Windows, fix bug causing newly created windows to erroneously display the "wait" (spinning) cursor. - On Windows, change the default window size (1024x768) to match the default on other desktop platforms (800x600). - On Windows, fix bug causing mouse capture to not be released. diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index b8df45151b..052a6592cb 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -448,7 +448,20 @@ impl Window { } pub fn request_redraw(&self) { - // TODO + match ndk_glue::native_window().as_ref() { + Some(native_window) => { + let a_native_window: *mut ndk_sys::ANativeWindow = native_window.ptr().as_ptr(); + let a_native_activity: *mut ndk_sys::ANativeActivity = + ndk_glue::native_activity().ptr().as_ptr(); + unsafe { + match (*(*a_native_activity).callbacks).onNativeWindowRedrawNeeded { + Some(callback) => callback(a_native_activity, a_native_window), + None => (), + }; + }; + } + None => (), + } } pub fn inner_position(&self) -> Result, error::NotSupportedError> {