Change Suspended(true/false) => Suspended/Resumed (#959)

This commit is contained in:
Felix Rabe 2019-06-22 04:59:31 +02:00 committed by Hal Gentz
parent 1193cada46
commit f457c6a0b8
6 changed files with 17 additions and 13 deletions

View file

@ -1,5 +1,7 @@
# Unreleased # Unreleased
- Change `Event::Suspended(true / false)` to `Event::Suspended` and `Event::Resumed`.
# 0.20.0 Alpha 1 # 0.20.0 Alpha 1
- Changes below are considered **breaking**. - Changes below are considered **breaking**.

View file

@ -37,10 +37,11 @@ pub enum Event<T> {
/// emitted, it is guaranteed to be the last event emitted. /// emitted, it is guaranteed to be the last event emitted.
LoopDestroyed, LoopDestroyed,
/// Emitted when the application has been suspended or resumed. /// Emitted when the application has been suspended.
/// Suspended,
/// The parameter is true if app was suspended, and false if it has been resumed.
Suspended(bool), /// Emitted when the application has been resumed.
Resumed,
} }
impl<T> Event<T> { impl<T> Event<T> {
@ -53,7 +54,8 @@ impl<T> Event<T> {
NewEvents(cause) => Ok(NewEvents(cause)), NewEvents(cause) => Ok(NewEvents(cause)),
EventsCleared => Ok(EventsCleared), EventsCleared => Ok(EventsCleared),
LoopDestroyed => Ok(LoopDestroyed), LoopDestroyed => Ok(LoopDestroyed),
Suspended(suspended) => Ok(Suspended(suspended)), Suspended => Ok(Suspended),
Resumed => Ok(Resumed),
} }
} }
} }

View file

@ -85,14 +85,14 @@ impl EventLoop {
if let Some(cb) = self.suspend_callback.borrow().as_ref() { if let Some(cb) = self.suspend_callback.borrow().as_ref() {
(*cb)(false); (*cb)(false);
} }
Some(Event::Suspended(false)) Some(Event::Resumed)
}, },
android_glue::Event::TermWindow => { android_glue::Event::TermWindow => {
// The activity went to background. // The activity went to background.
if let Some(cb) = self.suspend_callback.borrow().as_ref() { if let Some(cb) = self.suspend_callback.borrow().as_ref() {
(*cb)(true); (*cb)(true);
} }
Some(Event::Suspended(true)) Some(Event::Suspended)
}, },
android_glue::Event::WindowResized | android_glue::Event::ConfigChanged => { android_glue::Event::WindowResized | android_glue::Event::ConfigChanged => {
// Activity Orientation changed or resized. // Activity Orientation changed or resized.

View file

@ -46,8 +46,8 @@
//! //!
//! This is how those event are represented in winit: //! This is how those event are represented in winit:
//! //!
//! - applicationDidBecomeActive is Suspended(false) //! - applicationDidBecomeActive is Resumed
//! - applicationWillResignActive is Suspended(true) //! - applicationWillResignActive is Suspended
//! - applicationWillTerminate is LoopDestroyed //! - applicationWillTerminate is LoopDestroyed
//! //!
//! Keep in mind that after LoopDestroyed event is received every attempt to draw with //! Keep in mind that after LoopDestroyed event is received every attempt to draw with

View file

@ -382,11 +382,11 @@ pub fn create_delegate_class() {
} }
extern "C" fn did_become_active(_: &Object, _: Sel, _: id) { 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) { 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) {} extern "C" fn will_enter_foreground(_: &Object, _: Sel, _: id) {}

View file

@ -54,7 +54,7 @@ extern "C" fn did_finish_launching(_: &Object, _: Sel, _: id) -> BOOL {
extern "C" fn did_become_active(_: &Object, _: Sel, _: id) { extern "C" fn did_become_active(_: &Object, _: Sel, _: id) {
trace!("Triggered `didBecomeActive`"); trace!("Triggered `didBecomeActive`");
/*unsafe { /*unsafe {
HANDLER.lock().unwrap().handle_nonuser_event(Event::Suspended(false)) HANDLER.lock().unwrap().handle_nonuser_event(Event::Resumed)
}*/ }*/
trace!("Completed `didBecomeActive`"); 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) { extern "C" fn will_resign_active(_: &Object, _: Sel, _: id) {
trace!("Triggered `willResignActive`"); trace!("Triggered `willResignActive`");
/*unsafe { /*unsafe {
HANDLER.lock().unwrap().handle_nonuser_event(Event::Suspended(true)) HANDLER.lock().unwrap().handle_nonuser_event(Event::Suspended)
}*/ }*/
trace!("Completed `willResignActive`"); trace!("Completed `willResignActive`");
} }