Skip to content

Commit

Permalink
Several improvements to the iOS backend:
Browse files Browse the repository at this point in the history
- 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 01bfc21
Show file tree
Hide file tree
Showing 16 changed files with 980 additions and 732 deletions.
3 changes: 3 additions & 0 deletions include/SDL_config_iphoneos.h
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions premake/Xcode-iOS/SDL_config_premake.h
Expand Up @@ -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
Expand Down
25 changes: 14 additions & 11 deletions src/video/SDL_video.c
Expand Up @@ -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

Expand All @@ -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;
}
}

Expand Down Expand Up @@ -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) {
Expand All @@ -1182,7 +1186,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
SDL_RestoreMousePosition(other);

window->last_fullscreen_flags = window->flags;
return;
return 0;
}
}
}
Expand All @@ -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 \
Expand Down Expand Up @@ -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 *
Expand Down
16 changes: 13 additions & 3 deletions src/video/uikit/SDL_uikitappdelegate.h
Expand Up @@ -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.