diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f18343c..b7861ecb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased +- Change `Event::Suspended(true / false)` to `Event::Suspended` and `Event::Resumed`. + # 0.20.0 Alpha 1 - Changes below are considered **breaking**. diff --git a/src/event.rs b/src/event.rs index 3a6aeccb..26356e10 100644 --- a/src/event.rs +++ b/src/event.rs @@ -37,10 +37,11 @@ pub enum Event { /// emitted, it is guaranteed to be the last event emitted. LoopDestroyed, - /// Emitted when the application has been suspended or resumed. - /// - /// The parameter is true if app was suspended, and false if it has been resumed. - Suspended(bool), + /// Emitted when the application has been suspended. + Suspended, + + /// Emitted when the application has been resumed. + Resumed, } impl Event { @@ -53,7 +54,8 @@ impl Event { NewEvents(cause) => Ok(NewEvents(cause)), EventsCleared => Ok(EventsCleared), LoopDestroyed => Ok(LoopDestroyed), - Suspended(suspended) => Ok(Suspended(suspended)), + Suspended => Ok(Suspended), + Resumed => Ok(Resumed), } } } diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index a5b0139e..c286dfd8 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -85,14 +85,14 @@ impl EventLoop { if let Some(cb) = self.suspend_callback.borrow().as_ref() { (*cb)(false); } - Some(Event::Suspended(false)) + Some(Event::Resumed) }, android_glue::Event::TermWindow => { // The activity went to background. if let Some(cb) = self.suspend_callback.borrow().as_ref() { (*cb)(true); } - Some(Event::Suspended(true)) + Some(Event::Suspended) }, android_glue::Event::WindowResized | android_glue::Event::ConfigChanged => { // Activity Orientation changed or resized. diff --git a/src/platform_impl/ios/mod.rs b/src/platform_impl/ios/mod.rs index ae6f3f0f..dfb659f9 100644 --- a/src/platform_impl/ios/mod.rs +++ b/src/platform_impl/ios/mod.rs @@ -46,8 +46,8 @@ //! //! This is how those event are represented in winit: //! -//! - applicationDidBecomeActive is Suspended(false) -//! - applicationWillResignActive is Suspended(true) +//! - applicationDidBecomeActive is Resumed +//! - applicationWillResignActive is Suspended //! - applicationWillTerminate is LoopDestroyed //! //! Keep in mind that after LoopDestroyed event is received every attempt to draw with diff --git a/src/platform_impl/ios/view.rs b/src/platform_impl/ios/view.rs index f046cdba..b174b75a 100644 --- a/src/platform_impl/ios/view.rs +++ b/src/platform_impl/ios/view.rs @@ -382,11 +382,11 @@ pub fn create_delegate_class() { } extern "C" fn did_become_active(_: &Object, _: Sel, _: id) { - unsafe { AppState::handle_nonuser_event(Event::Suspended(false)) } + unsafe { AppState::handle_nonuser_event(Event::Resumed) } } extern "C" fn will_resign_active(_: &Object, _: Sel, _: id) { - unsafe { AppState::handle_nonuser_event(Event::Suspended(true)) } + unsafe { AppState::handle_nonuser_event(Event::Suspended) } } extern "C" fn will_enter_foreground(_: &Object, _: Sel, _: id) {} diff --git a/src/platform_impl/macos/app_delegate.rs b/src/platform_impl/macos/app_delegate.rs index 7983503b..c0c3a121 100644 --- a/src/platform_impl/macos/app_delegate.rs +++ b/src/platform_impl/macos/app_delegate.rs @@ -54,7 +54,7 @@ extern "C" fn did_finish_launching(_: &Object, _: Sel, _: id) -> BOOL { extern "C" fn did_become_active(_: &Object, _: Sel, _: id) { trace!("Triggered `didBecomeActive`"); /*unsafe { - HANDLER.lock().unwrap().handle_nonuser_event(Event::Suspended(false)) + HANDLER.lock().unwrap().handle_nonuser_event(Event::Resumed) }*/ trace!("Completed `didBecomeActive`"); } @@ -62,7 +62,7 @@ extern "C" fn did_become_active(_: &Object, _: Sel, _: id) { extern "C" fn will_resign_active(_: &Object, _: Sel, _: id) { trace!("Triggered `willResignActive`"); /*unsafe { - HANDLER.lock().unwrap().handle_nonuser_event(Event::Suspended(true)) + HANDLER.lock().unwrap().handle_nonuser_event(Event::Suspended) }*/ trace!("Completed `willResignActive`"); }