Skip to content
Permalink
Browse files

Several improvements to the iOS backend:

- Added new custom launch screen code. It uses the launch screen nib when available on iOS 8+, the launch images dictionary if the launch screen nib isn't available, and the old standard image names if the launch image dictionary isn't in the plist.
The launch screen is now hidden during the first call to SDL_PumpEvents rather than SDL_CreateWindow so apps can have the launch screen still visible if they do time-consuming loading after creating their window. It also fades out in roughly the same way as the system launch screen behavior.
It can be disabled by setting the SDL_IPHONE_LAUNCHSCREEN define in SDL_config_iphoneos.h to 0.

- A blank UIView is now created and displayed when the window is first created. The old behavior was to defer creating any view until SDL_GL_CreateContext, which prevented rotation, touch events, and other windowing-related things from working until then. This also makes it easier to use SDL_GetWindowWMInfo after creating a window.

- Moved the keyboard and animation callback code from SDL's UIView subclasses to its UIViewController subclass, which lets them work properly in all cases when a SDL window is valid, even before SDL_GL_CreateContext is called and after SDL_GL_DeleteContext is called.

- SDL_GL_CreateContext, SDL_GL_SwapWindow, SDL_GL_MakeCurrent, and SDL_GL_DeleteContext are more robust.

- Fixed some edge cases where SDL windows weren't rotating properly or their reported sizes were out of sync with their actual sizes.

- Removed all calls to [UIApplication setStatusBarOrientation:]. It doesn't seem to work as expected in all cases in recent iOS versions.

- Some code style cleanup.
  • Loading branch information
slime73 committed Jan 15, 2015
1 parent cc0631a commit 01bfc2158a3b60450057e67ec6011a6381037110
@@ -145,6 +145,9 @@
/* enable iPhone keyboard support */
#define SDL_IPHONE_KEYBOARD 1

/* enable iOS extended launch screen */
#define SDL_IPHONE_LAUNCHSCREEN 1

/* enable joystick subsystem */
#define SDL_JOYSTICK_DISABLED 0

@@ -126,6 +126,9 @@
#ifndef SDL_IPHONE_KEYBOARD
#define SDL_IPHONE_KEYBOARD 1
#endif
#ifndef SDL_IPHONE_LAUNCHSCREEN
#define SDL_IPHONE_LAUNCHSCREEN 1
#endif
#ifndef SDL_POWER_UIKIT
#define SDL_POWER_UIKIT 1
#endif
@@ -1100,22 +1100,22 @@ SDL_RestoreMousePosition(SDL_Window *window)
}
}

static void
static int
SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
{
SDL_VideoDisplay *display;
SDL_Window *other;

CHECK_WINDOW_MAGIC(window,);
CHECK_WINDOW_MAGIC(window,-1);

/* if we are in the process of hiding don't go back to fullscreen */
if ( window->is_hiding && fullscreen )
return;
return 0;

#ifdef __MACOSX__
if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) {
window->last_fullscreen_flags = window->flags;
return;
return 0;
}
#endif

@@ -1132,7 +1132,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
/* See if anything needs to be done now */
if ((display->fullscreen_window == window) == fullscreen) {
if ((window->last_fullscreen_flags & FULLSCREEN_MASK) == (window->flags & FULLSCREEN_MASK)) {
return;
return 0;
}
}

@@ -1161,9 +1161,13 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)

/* only do the mode change if we want exclusive fullscreen */
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
SDL_SetDisplayModeForDisplay(display, &fullscreen_mode);
if (SDL_SetDisplayModeForDisplay(display, &fullscreen_mode) < 0) {
return -1;
}
} else {
SDL_SetDisplayModeForDisplay(display, NULL);
if (SDL_SetDisplayModeForDisplay(display, NULL) < 0) {
return -1;
}
}

if (_this->SetWindowFullscreen) {
@@ -1182,7 +1186,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
SDL_RestoreMousePosition(other);

window->last_fullscreen_flags = window->flags;
return;
return 0;
}
}
}
@@ -1202,6 +1206,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
SDL_RestoreMousePosition(window);

window->last_fullscreen_flags = window->flags;
return 0;
}

#define CREATE_FLAGS \
@@ -1927,9 +1932,7 @@ SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
window->flags &= ~FULLSCREEN_MASK;
window->flags |= flags;

SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window));

return 0;
return SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window));
}

static SDL_Surface *
@@ -21,12 +21,22 @@

#import <UIKit/UIKit.h>

@interface SDLUIKitDelegate : NSObject<UIApplicationDelegate> {
}
@interface SDLLaunchScreenController : UIViewController

+ (id) sharedAppDelegate;
- (instancetype)init;
- (void)loadView;
- (BOOL)shouldAutorotate;
- (NSUInteger)supportedInterfaceOrientations;

@end

@interface SDLUIKitDelegate : NSObject<UIApplicationDelegate>

+ (id)sharedAppDelegate;
+ (NSString *)getAppDelegateClassName;

- (void)hideLaunchScreen;

@end

/* vi: set ts=4 sw=4 expandtab: */

0 comments on commit 01bfc21

Please sign in to comment.