Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ pub trait EventHandler {

/// Window has been restored
/// Right now is only implemented on Android, X11 and wasm,
/// On Andoid window_minimized_event is called on a Pause ndk callback
/// On Andoid window_restored_event is called on a Resume ndk callback
/// On X11 and wasm it will be called on focus change events.
fn window_restored_event(&mut self) {}

Expand All @@ -222,6 +222,7 @@ pub trait EventHandler {
/// handler callback code can handle this event by calling
/// ctx.cancel_quit() to cancel the quit.
/// If the event is ignored, the application will quit as usual.
/// On Andoid quit_requested_event is called on a Destroy ndk callback
fn quit_requested_event(&mut self) {}

/// A file has been dropped over the application.
Expand Down
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@
.set(Mutex::new(display))
.unwrap_or_else(|_| panic!("NATIVE_DISPLAY already set"));
}
/// This for now is Android specific since the process can continue running but the display
/// is restarted. We support reinitializing the display.
fn set_or_replace_display(display: native::NativeDisplayData) {

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (macos-latest, x86_64-apple-ios)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (macos-latest, aarch64-apple-ios)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (macos-latest, x86_64-apple-darwin)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, x86_64-pc-windows-msvc)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, x86_64-unknown-linux-gnu)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, x86_64-pc-windows-gnu)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, armv7-unknown-linux-gnueabihf)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, aarch64-unknown-linux-gnu)

function `set_or_replace_display` is never used

Check warning on line 102 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, wasm32-unknown-unknown)

function `set_or_replace_display` is never used
if let Some(m) = NATIVE_DISPLAY.get() {
// Replace existing display
*m.lock().unwrap() = display;
} else {
// First time initialization
set_display(display);
}
}
fn native_display() -> &'static Mutex<native::NativeDisplayData> {
NATIVE_DISPLAY
.get()
Expand Down
6 changes: 1 addition & 5 deletions src/native/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,6 @@ impl MainThreadState {
width,
height,
} => {
unsafe {
self.update_surface(window);
}

{
let mut d = crate::native_display().lock().unwrap();
d.screen_width = width as _;
Expand Down Expand Up @@ -450,7 +446,7 @@ where

let (tx, requests_rx) = std::sync::mpsc::channel();
let clipboard = Box::new(AndroidClipboard::new());
crate::set_display(NativeDisplayData {
crate::set_or_replace_display(NativeDisplayData {
high_dpi: conf.high_dpi,
blocking_event_loop: conf.platform.blocking_event_loop,
..NativeDisplayData::new(screen_width as _, screen_height as _, tx, clipboard)
Expand Down
Loading