Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ pub enum Event<'a, T: 'static> {
/// Emitted when the application has been resumed.
Resumed,

/// Emitted when the application will enter the foreground.
Foreground,

/// Emitted when the application has entered the background.
Background,

/// Emitted when all of the event loop's input events have been processed and redraw processing
/// is about to begin.
///
Expand Down Expand Up @@ -138,6 +144,8 @@ impl<T: Clone> Clone for Event<'static, T> {
LoopDestroyed => LoopDestroyed,
Suspended => Suspended,
Resumed => Resumed,
Foreground => Foreground,
Background => Background,
}
}
}
Expand All @@ -156,6 +164,8 @@ impl<'a, T> Event<'a, T> {
LoopDestroyed => Ok(LoopDestroyed),
Suspended => Ok(Suspended),
Resumed => Ok(Resumed),
Foreground => Ok(Foreground),
Background => Ok(Background),
}
}

Expand All @@ -176,6 +186,8 @@ impl<'a, T> Event<'a, T> {
LoopDestroyed => Some(LoopDestroyed),
Suspended => Some(Suspended),
Resumed => Some(Resumed),
Foreground => Some(Foreground),
Background => Some(Background),
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/platform_impl/ios/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,13 @@ pub fn create_delegate_class() {
unsafe { app_state::handle_nonuser_event(EventWrapper::StaticEvent(Event::Suspended)) }
}

extern "C" fn will_enter_foreground(_: &Object, _: Sel, _: id) {}
extern "C" fn did_enter_background(_: &Object, _: Sel, _: id) {}
extern "C" fn will_enter_foreground(_: &Object, _: Sel, _: id) {
unsafe { app_state::handle_nonuser_event(EventWrapper::StaticEvent(Event::Foreground)) }
}

extern "C" fn did_enter_background(_: &Object, _: Sel, _: id) {
unsafe { app_state::handle_nonuser_event(EventWrapper::StaticEvent(Event::Background)) }
}

extern "C" fn will_terminate(_: &Object, _: Sel, _: id) {
unsafe {
Expand Down