Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: allow EventLoop recreation #3353

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Unreleased` header.

# Unreleased

- On Android, allow EventLoop recreation after destruction
- On X11 and Wayland, fix arrow up on keypad reported as `ArrowLeft`.
- On Windows, macOS, X11, Wayland and Web, implement setting images as cursors. See the `custom_cursors.rs` example.
- **Breaking:** Remove `Window::set_cursor_icon`
Expand Down
5 changes: 4 additions & 1 deletion src/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ impl<T> EventLoopBuilder<T> {
/// or `DISPLAY` respectively when building the event loop.
/// - **Android:** must be configured with an `AndroidApp` from `android_main()` by calling
/// [`.with_android_app(app)`] before calling `.build()`, otherwise it'll panic.
/// Due to android platform-specific behaviour, it's possible to recreate the EventLoop
/// after the previous one has been destroyed, this is to prevent bugs when multiple
/// activities are used.
///
/// [`platform`]: crate::platform
#[cfg_attr(
Expand All @@ -130,7 +133,7 @@ impl<T> EventLoopBuilder<T> {
})
}

#[cfg(wasm_platform)]
#[cfg(any(wasm_platform, android_platform))]
pub(crate) fn allow_event_loop_recreation() {
EVENT_LOOP_CREATED.store(false, Ordering::Relaxed);
}
Expand Down
6 changes: 6 additions & 0 deletions src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,12 @@ impl<T: 'static> EventLoop<T> {
}
}

impl<T> Drop for EventLoop<T> {
fn drop(&mut self) {
crate::event_loop::EventLoopBuilder::<()>::allow_event_loop_recreation();
}
}

pub struct EventLoopProxy<T: 'static> {
user_events_sender: mpsc::Sender<T>,
waker: AndroidAppWaker,
Expand Down