Skip to content

Commit

Permalink
Change Suspended(true/false) => Suspended/Resumed (rust-windowing…
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrabe authored and goddessfreya committed Jun 22, 2019
1 parent 1193cad commit f457c6a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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**.
Expand Down
12 changes: 7 additions & 5 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ pub enum Event<T> {
/// 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<T> Event<T> {
Expand All @@ -53,7 +54,8 @@ impl<T> Event<T> {
NewEvents(cause) => Ok(NewEvents(cause)),
EventsCleared => Ok(EventsCleared),
LoopDestroyed => Ok(LoopDestroyed),
Suspended(suspended) => Ok(Suspended(suspended)),
Suspended => Ok(Suspended),
Resumed => Ok(Resumed),
}
}
}
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 @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/ios/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/ios/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/macos/app_delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ 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`");
}

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`");
}
Expand Down

0 comments on commit f457c6a

Please sign in to comment.