Skip to content

Commit

Permalink
android: add ActiveEventLoopExtAndroid::android_app
Browse files Browse the repository at this point in the history
This type comes from the user and stored for the entire lifetime, so
no need to hide it from them after they've passed it to winit.

Fixes #3818.
  • Loading branch information
kchibisov committed Jul 26, 2024
1 parent 4e2e764 commit 696cdef
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/changelog/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 9 additions & 2 deletions src/platform/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {}
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Init>`
Expand Down Expand Up @@ -575,7 +575,7 @@ impl EventLoopProxy {
}

pub struct ActiveEventLoop {
app: AndroidApp,
pub(crate) app: AndroidApp,
control_flow: Cell<ControlFlow>,
exit: Cell<bool>,
redraw_requester: RedrawRequester,
Expand Down

0 comments on commit 696cdef

Please sign in to comment.