21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_UIKIT 30 #include "../SDL_sysvideo.h" 31 #include "../SDL_pixels_c.h" 32 #include "../../events/SDL_events_c.h" 43 #include <Foundation/Foundation.h> 53 if ((
self = [super init])) {
54 views = [NSMutableArray new];
62 @interface SDL_uikitwindow : UIWindow
64 - (
void)layoutSubviews;
68 @implementation SDL_uikitwindow
70 - (
void)layoutSubviews
73 self.frame =
self.screen.bounds;
74 [
super layoutSubviews];
86 CGRect
frame = UIKit_ComputeViewFrame(window, displaydata.
uiscreen);
95 window->
driverdata = (
void *) CFBridgingRetain(data);
102 if (displaydata.
uiscreen != [UIScreen mainScreen]) {
109 if (displaydata.
uiscreen == [UIScreen mainScreen]) {
119 BOOL supportsLandscape = (orients & UIInterfaceOrientationMaskLandscape) != 0;
120 BOOL supportsPortrait = (orients & (UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown)) != 0;
123 if ((width >
height && !supportsLandscape) || (
height > width && !supportsPortrait)) {
146 [view setSDLWindow:window];
149 if (displaydata.
uiscreen == [UIScreen mainScreen]) {
169 return SDL_SetError(
"Only one window allowed per display.");
176 const CGSize origsize = data.
uiscreen.currentMode.size;
177 if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) {
186 if ((mode->
w >= window->
w) && (mode->
h >= window->
h)) {
202 if (data.
uiscreen == [UIScreen mainScreen]) {
204 [UIApplication sharedApplication].statusBarHidden = YES;
206 [UIApplication sharedApplication].statusBarHidden = NO;
213 UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:data.uiscreen.bounds];
216 if (data.
uiscreen != [UIScreen mainScreen]) {
217 [uiwindow setScreen:data.uiscreen];
220 if (SetupWindowData(
_this, window, uiwindow,
SDL_TRUE) < 0) {
272 if (data.
uiwindow.screen == [UIScreen mainScreen]) {
274 [UIApplication sharedApplication].statusBarHidden = YES;
276 [UIApplication sharedApplication].statusBarHidden = NO;
280 if ([
viewcontroller respondsToSelector:
@selector(setNeedsStatusBarAppearanceUpdate)]) {
281 [viewcontroller setNeedsStatusBarAppearanceUpdate];
289 #ifdef SDL_IPHONE_KEYBOARD 291 [viewcontroller updateKeyboard];
294 [viewcontroller.view setNeedsLayout];
295 [viewcontroller.view layoutIfNeeded];
302 UIKit_UpdateWindowBorder(
_this, window);
310 UIKit_UpdateWindowBorder(
_this, window);
320 NSArray *
views = nil;
322 [data.viewcontroller stopAnimation];
327 views = [data.views copy];
329 [view setSDLWindow:NULL];
336 data.
uiwindow.rootViewController = nil;
358 SDL_uikitopenglview *glview = (SDL_uikitopenglview *)data.
viewcontroller.view;
363 info->
info.uikit.framebuffer = 0;
364 info->
info.uikit.colorbuffer = 0;
365 info->
info.uikit.resolveFramebuffer = 0;
383 NSUInteger validOrientations = UIInterfaceOrientationMaskAll;
384 NSUInteger orientationMask = 0;
388 UIApplication *app = [UIApplication sharedApplication];
392 if ([app.delegate respondsToSelector:
@selector(application:supportedInterfaceOrientationsForWindow:)]) {
393 validOrientations = [app.delegate application:app supportedInterfaceOrientationsForWindow:data.uiwindow];
394 }
else if ([app respondsToSelector:
@selector(supportedInterfaceOrientationsForWindow:)]) {
395 validOrientations = [app supportedInterfaceOrientationsForWindow:data.uiwindow];
399 NSArray *orientations = [@(hint) componentsSeparatedByString:@" "];
401 if ([orientations containsObject:
@"LandscapeLeft"]) {
402 orientationMask |= UIInterfaceOrientationMaskLandscapeLeft;
404 if ([orientations containsObject:
@"LandscapeRight"]) {
405 orientationMask |= UIInterfaceOrientationMaskLandscapeRight;
407 if ([orientations containsObject:
@"Portrait"]) {
408 orientationMask |= UIInterfaceOrientationMaskPortrait;
410 if ([orientations containsObject:
@"PortraitUpsideDown"]) {
411 orientationMask |= UIInterfaceOrientationMaskPortraitUpsideDown;
417 orientationMask = UIInterfaceOrientationMaskAll;
420 if (orientationMask == 0) {
421 if (window->
w >= window->
h) {
422 orientationMask |= UIInterfaceOrientationMaskLandscape;
424 if (window->
h >= window->
w) {
425 orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
430 if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
431 orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown;
437 if ((validOrientations & orientationMask) == 0) {
438 orientationMask = validOrientations;
442 return orientationMask;
457 callbackParam:callbackParam];
#define SDL_MINOR_VERSION
SDL_bool UIKit_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
void SDL_SetKeyboardFocus(SDL_Window *window)
int UIKit_CreateWindow(_THIS, SDL_Window *window)
GLuint drawableRenderbuffer
void UIKit_DestroyWindow(_THIS, SDL_Window *window)
#define SDL_MAJOR_VERSION
SDL_uikitviewcontroller * viewcontroller
The structure that defines a display mode.
void UIKit_SetWindowTitle(_THIS, SDL_Window *window)
void UIKit_RaiseWindow(_THIS, SDL_Window *window)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void UIKit_HideWindow(_THIS, SDL_Window *window)
void SDL_SetMouseFocus(SDL_Window *window)
GLuint drawableFramebuffer
GLuint msaaResolveFramebuffer
void UIKit_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
NSUInteger UIKit_GetSupportedOrientations(SDL_Window *window)
GLint GLint GLsizei width
static SDL_VideoDevice * _this
SDL_GLContext current_glctx
void UIKit_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
#define SDL_VERSIONNUM(X, Y, Z)
SDL_DisplayMode * display_modes
SDL_DisplayMode current_mode
static Uint32 callback(Uint32 interval, void *param)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_assert(condition)
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
#define SDL_HINT_ORIENTATIONS
A variable controlling which orientations are allowed on iOS.
#define SDL_OutOfMemory()
GLint GLint GLsizei GLsizei height
UIScreenMode * uiscreenmode
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
EGLSurface EGLNativeWindowType * window
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
The type used to identify a window.
union SDL_SysWMinfo::@18 info
void UIKit_ShowWindow(_THIS, SDL_Window *window)
SDL_Window * current_glwin
#define SDL_iPhoneSetAnimationCallback