api: add ApplicationHandler and matching run APIs
Add a simple `ApplicationHandler` trait since winit is moving towards trait based API. Add `run_app` group of APIs to accept `&mut impl ApplicationHandler` deprecating the old `run` APIs. Part-of: https://github.com/rust-windowing/winit/issues/3432
This commit is contained in:
parent
fc8a008b25
commit
d123cd2f8e
18 changed files with 821 additions and 651 deletions
|
|
@ -182,7 +182,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
application.is_none(),
|
||||
"\
|
||||
`EventLoop` cannot be `run` after a call to `UIApplicationMain` on iOS\n\
|
||||
Note: `EventLoop::run` calls `UIApplicationMain` on iOS",
|
||||
Note: `EventLoop::run_app` calls `UIApplicationMain` on iOS",
|
||||
);
|
||||
|
||||
let handler = map_user_event(handler, self.receiver);
|
||||
|
|
|
|||
|
|
@ -689,7 +689,7 @@ impl Inner {
|
|||
let screen_frame = self.rect_to_screen_space(bounds);
|
||||
let status_bar_frame = {
|
||||
let app = UIApplication::shared(MainThreadMarker::new().unwrap()).expect(
|
||||
"`Window::get_inner_position` cannot be called before `EventLoop::run` on iOS",
|
||||
"`Window::get_inner_position` cannot be called before `EventLoop::run_app` on iOS",
|
||||
);
|
||||
app.statusBarFrame()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ declare_class!(
|
|||
self.set_is_running(true);
|
||||
self.dispatch_init_events();
|
||||
|
||||
// If the application is being launched via `EventLoop::pump_events()` then we'll
|
||||
// If the application is being launched via `EventLoop::pump_app_events()` then we'll
|
||||
// want to stop the app once it is launched (and return to the external loop)
|
||||
//
|
||||
// In this case we still want to consider Winit's `EventLoop` to be "running",
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ enum RunnerEnum {
|
|||
Pending,
|
||||
/// The `EventLoop` is being run.
|
||||
Running(Runner),
|
||||
/// The `EventLoop` is exited after being started with `EventLoop::run`. Since
|
||||
/// `EventLoop::run` takes ownership of the `EventLoop`, we can be certain
|
||||
/// The `EventLoop` is exited after being started with `EventLoop::run_app`. Since
|
||||
/// `EventLoop::run_app` takes ownership of the `EventLoop`, we can be certain
|
||||
/// that this event loop will never be run again.
|
||||
Destroyed,
|
||||
}
|
||||
|
|
@ -735,7 +735,7 @@ impl Shared {
|
|||
// * `self`, i.e. the item which triggered this event loop wakeup, which
|
||||
// is usually a `wasm-bindgen` `Closure`, which will be dropped after
|
||||
// returning to the JS glue code.
|
||||
// * The `ActiveEventLoop` leaked inside `EventLoop::run` due to the
|
||||
// * The `ActiveEventLoop` leaked inside `EventLoop::run_app` due to the
|
||||
// JS exception thrown at the end.
|
||||
// * For each undropped `Window`:
|
||||
// * The `register_redraw_request` closure.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue