diff --git a/src/changelog/unreleased.md b/src/changelog/unreleased.md index 08e2fe9179..d43db3eaac 100644 --- a/src/changelog/unreleased.md +++ b/src/changelog/unreleased.md @@ -54,6 +54,7 @@ changelog entry. `ActiveEventLoop::request_detailed_monitor_permission()`, access to all monitors and their information is available. This "detailed monitors" can be used in `Window::set_fullscreen()` as well. +- On Android, add `ActiveEventLoopExtAndroid::android_app` to access the app used to create the loop. ### Changed diff --git a/src/platform/android.rs b/src/platform/android.rs index 2dd596ebfa..f33e911cae 100644 --- a/src/platform/android.rs +++ b/src/platform/android.rs @@ -80,7 +80,10 @@ pub trait EventLoopExtAndroid {} impl EventLoopExtAndroid for EventLoop {} /// Additional methods on [`ActiveEventLoop`] that are specific to Android. -pub trait ActiveEventLoopExtAndroid {} +pub trait ActiveEventLoopExtAndroid { + /// Get the `AndroidApp` which was used to create an event loop. + fn android_app(&self) -> &AndroidApp; +} /// Additional methods on [`Window`] that are specific to Android. pub trait WindowExtAndroid { @@ -99,7 +102,11 @@ impl WindowExtAndroid for Window { } } -impl ActiveEventLoopExtAndroid for ActiveEventLoop {} +impl ActiveEventLoopExtAndroid for ActiveEventLoop { + fn android_app(&self) -> &AndroidApp { + &self.p.app + } +} /// Additional methods on [`WindowAttributes`] that are specific to Android. pub trait WindowAttributesExtAndroid {} diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index badbc3c504..7a5526f779 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -98,7 +98,7 @@ impl RedrawRequester { pub struct KeyEventExtra {} pub struct EventLoop { - android_app: AndroidApp, + pub(crate) android_app: AndroidApp, window_target: event_loop::ActiveEventLoop, redraw_flag: SharedFlag, loop_running: bool, // Dispatched `NewEvents` @@ -575,7 +575,7 @@ impl EventLoopProxy { } pub struct ActiveEventLoop { - app: AndroidApp, + pub(crate) app: AndroidApp, control_flow: Cell, exit: Cell, redraw_requester: RedrawRequester,