Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .changes/will-enter-foreground.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": minor
---

Add WillEnterForeground event for iOS.
9 changes: 9 additions & 0 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ pub enum Event<'a, T: 'static> {
/// - **Other**: Unsupported.
#[non_exhaustive]
Reopen { has_visible_windows: bool },

/// ## Platform-specific
///
/// - **iOS**: https://developer.apple.com/documentation/uikit/uiapplicationdelegate/applicationwillenterforeground(_:)
/// - **Other**: Unsupported.
WillEnterForeground,
}

impl<T: Clone> Clone for Event<'static, T> {
Expand Down Expand Up @@ -170,6 +176,7 @@ impl<T: Clone> Clone for Event<'static, T> {
} => Reopen {
has_visible_windows: *has_visible_windows,
},
WillEnterForeground => WillEnterForeground,
}
}
}
Expand All @@ -194,6 +201,7 @@ impl<'a, T> Event<'a, T> {
} => Ok(Reopen {
has_visible_windows,
}),
WillEnterForeground => Ok(WillEnterForeground),
}
}

Expand All @@ -220,6 +228,7 @@ impl<'a, T> Event<'a, T> {
} => Some(Reopen {
has_visible_windows,
}),
WillEnterForeground => Some(WillEnterForeground),
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/platform_impl/ios/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,12 @@ 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 will_enter_foreground(_: &Object, _: Sel, _: id) {
unsafe {
app_state::handle_nonuser_event(EventWrapper::StaticEvent(Event::WillEnterForeground))
}
}

extern "C" fn did_enter_background(_: &Object, _: Sel, _: id) {}

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