Bring back iOS application delegates and fix many issues #6453
+158
−71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After going through separate issues that ask for having access to a custom app delegate class, and specifically after #6449 / libsdl-org/SDL#11627, I've looked into bringing app delegate classes back.
Reading the SDL's codebase and various PRs in the repo, I've noticed that SDL intentionally doesn't do anything special/internal for its API in the app delegate class it uses for the application. This is to allow consumers that wish for a custom app delegate class to create one without extra effort (although I had to do this 3134295).
In order to use SDL without their own app delegate class, the
SDL_RunApp
should be omitted and we should callUIApplication.Main
on our app delegate class directly instead, and atfinishedLaunching
, we just have to callSDL_SetMainReady
to mark it as ready for initialisation.For detailed reasons as to why this PR exists:
GameApplication.main
. Disabling the UIKit event pump causes the application to not receive will/did enter background/foreground events, therefore never suspending/unfocusing when sent to background.UIApplicationDelegate
class to control the list of allowed orientations, to add support for Disable screen rotation while in active gameplay osu#5331UIApplicationDelegate
class is mandatory to have in any application for full flexibility over the app's configuration/behaviour, as well as handling various app-level events which may otherwise require asking SDL to add while not being of priority to them.