Skip to content

Commit

Permalink
Android: Don't emit ::Resized after MainEventsCleared
Browse files Browse the repository at this point in the history
This makes sure that `WindowEvent::Resized` events are always dispatched
before `MainEventsCleared` within `single_iteration()`

Applications will only expect `RedrawRequested` events between
`MainEventsCleared` and `RedrawEventsCleared`
  • Loading branch information
rib committed Mar 17, 2023
1 parent b2a4b65 commit 0032e23
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,21 @@ impl<T: 'static> EventLoop<T> {
}
}

if self.running && resized {
let size = if let Some(native_window) = self.android_app.native_window().as_ref() {
let width = native_window.width() as _;
let height = native_window.height() as _;
PhysicalSize::new(width, height)
} else {
PhysicalSize::new(0, 0)
};
let event = event::Event::WindowEvent {
window_id: window::WindowId(WindowId),
event: event::WindowEvent::Resized(size),
};
sticky_exit_callback(event, self.window_target(), control_flow, callback);
}

sticky_exit_callback(
event::Event::MainEventsCleared,
self.window_target(),
Expand All @@ -604,21 +619,6 @@ impl<T: 'static> EventLoop<T> {
);

if self.running {
if resized {
let size = if let Some(native_window) = self.android_app.native_window().as_ref() {
let width = native_window.width() as _;
let height = native_window.height() as _;
PhysicalSize::new(width, height)
} else {
PhysicalSize::new(0, 0)
};
let event = event::Event::WindowEvent {
window_id: window::WindowId(WindowId),
event: event::WindowEvent::Resized(size),
};
sticky_exit_callback(event, self.window_target(), control_flow, callback);
}

*pending_redraw |= self.redraw_flag.get_and_reset();
if *pending_redraw {
*pending_redraw = false;
Expand Down

0 comments on commit 0032e23

Please sign in to comment.