mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 13:31:29 +11:00
Change Suspended(true/false)
=> Suspended/Resumed
(#959)
This commit is contained in:
parent
1193cada46
commit
f457c6a0b8
|
@ -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**.
|
||||||
|
|
12
src/event.rs
12
src/event.rs
|
@ -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),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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) {}
|
||||||
|
|
|
@ -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`");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue