Fixed SDL_SetWindowFullscreen on iOS for the last time, hopefully.
Fixed iOS version checking code.main
parent
ef0490a741
commit
029e0193c5
|
@ -116,6 +116,7 @@ UIKit_GL_CreateContext(_THIS, SDL_Window * window)
|
||||||
SDL_uikitopenglview *view;
|
SDL_uikitopenglview *view;
|
||||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||||
UIWindow *uiwindow = data->uiwindow;
|
UIWindow *uiwindow = data->uiwindow;
|
||||||
|
CGRect frame = UIKit_ComputeViewFrame(window, uiwindow.screen);
|
||||||
EAGLSharegroup *share_group = nil;
|
EAGLSharegroup *share_group = nil;
|
||||||
CGFloat scale = 1.0;
|
CGFloat scale = 1.0;
|
||||||
|
|
||||||
|
@ -124,7 +125,7 @@ UIKit_GL_CreateContext(_THIS, SDL_Window * window)
|
||||||
dimensions of the OpenGL view will match the pixel dimensions of the
|
dimensions of the OpenGL view will match the pixel dimensions of the
|
||||||
screen rather than the dimensions in points.
|
screen rather than the dimensions in points.
|
||||||
*/
|
*/
|
||||||
scale = [uiwindow screen].scale;
|
scale = uiwindow.screen.scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_this->gl_config.share_with_current_context) {
|
if (_this->gl_config.share_with_current_context) {
|
||||||
|
@ -132,13 +133,6 @@ UIKit_GL_CreateContext(_THIS, SDL_Window * window)
|
||||||
share_group = [view.context sharegroup];
|
share_group = [view.context sharegroup];
|
||||||
}
|
}
|
||||||
|
|
||||||
CGRect frame;
|
|
||||||
if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
|
|
||||||
frame = [[uiwindow screen] bounds];
|
|
||||||
} else {
|
|
||||||
frame = [[uiwindow screen] applicationFrame];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* construct our view, passing in SDL's OpenGL configuration data */
|
/* construct our view, passing in SDL's OpenGL configuration data */
|
||||||
view = [[SDL_uikitopenglview alloc] initWithFrame: frame
|
view = [[SDL_uikitopenglview alloc] initWithFrame: frame
|
||||||
scale: scale
|
scale: scale
|
||||||
|
@ -175,7 +169,7 @@ UIKit_GL_CreateContext(_THIS, SDL_Window * window)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make this window the current mouse focus for touch input */
|
/* Make this window the current mouse focus for touch input */
|
||||||
if ([uiwindow screen] == [UIScreen mainScreen]) {
|
if (uiwindow.screen == [UIScreen mainScreen]) {
|
||||||
SDL_SetMouseFocus(window);
|
SDL_SetMouseFocus(window);
|
||||||
SDL_SetKeyboardFocus(window);
|
SDL_SetKeyboardFocus(window);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <OpenGLES/EAGLDrawable.h>
|
#include <OpenGLES/EAGLDrawable.h>
|
||||||
#include "SDL_uikitopenglview.h"
|
#include "SDL_uikitopenglview.h"
|
||||||
#include "SDL_uikitmessagebox.h"
|
#include "SDL_uikitmessagebox.h"
|
||||||
|
#include "SDL_uikitvideo.h"
|
||||||
|
|
||||||
|
|
||||||
@implementation SDL_uikitopenglview {
|
@implementation SDL_uikitopenglview {
|
||||||
|
@ -89,8 +90,7 @@
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL hasiOS7 = [[UIDevice currentDevice].systemVersion compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending;
|
if (sRGB && UIKit_IsSystemVersionAtLeast(@"7.0")) {
|
||||||
if (sRGB && hasiOS7) {
|
|
||||||
/* sRGB EAGL drawable support was added in iOS 7 */
|
/* sRGB EAGL drawable support was added in iOS 7 */
|
||||||
colorFormat = kEAGLColorFormatSRGBA8;
|
colorFormat = kEAGLColorFormatSRGBA8;
|
||||||
} else if (rBits >= 8 && gBits >= 8 && bBits >= 8) {
|
} else if (rBits >= 8 && gBits >= 8 && bBits >= 8) {
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
#include "../SDL_sysvideo.h"
|
#include "../SDL_sysvideo.h"
|
||||||
|
|
||||||
|
BOOL UIKit_IsSystemVersionAtLeast(NSString *version);
|
||||||
|
CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen);
|
||||||
|
|
||||||
#endif /* _SDL_uikitvideo_h */
|
#endif /* _SDL_uikitvideo_h */
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,26 @@ UIKit_VideoQuit(_THIS)
|
||||||
UIKit_QuitModes(_this);
|
UIKit_QuitModes(_this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
UIKit_IsSystemVersionAtLeast(NSString *version)
|
||||||
|
{
|
||||||
|
NSString *sysversion = [UIDevice currentDevice].systemVersion;
|
||||||
|
return [sysversion compare:version options:NSNumericSearch] != NSOrderedAscending;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGRect
|
||||||
|
UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen)
|
||||||
|
{
|
||||||
|
BOOL hasiOS7 = UIKit_IsSystemVersionAtLeast(@"7.0");
|
||||||
|
|
||||||
|
if (hasiOS7 || (window->flags & (SDL_WINDOW_BORDERLESS|SDL_WINDOW_FULLSCREEN))) {
|
||||||
|
/* The view should always show behind the status bar in iOS 7+. */
|
||||||
|
return screen.bounds;
|
||||||
|
} else {
|
||||||
|
return screen.applicationFrame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* iOS log support.
|
* iOS log support.
|
||||||
*
|
*
|
||||||
|
|
|
@ -62,16 +62,11 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
|
||||||
window->x = 0;
|
window->x = 0;
|
||||||
window->y = 0;
|
window->y = 0;
|
||||||
|
|
||||||
CGRect bounds;
|
CGRect frame = UIKit_ComputeViewFrame(window, displaydata->uiscreen);
|
||||||
if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
|
|
||||||
bounds = [displaydata->uiscreen bounds];
|
|
||||||
} else {
|
|
||||||
bounds = [displaydata->uiscreen applicationFrame];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get frame dimensions */
|
/* Get frame dimensions */
|
||||||
int width = (int) bounds.size.width;
|
int width = (int) frame.size.width;
|
||||||
int height = (int) bounds.size.height;
|
int height = (int) frame.size.height;
|
||||||
|
|
||||||
/* Make sure the width/height are oriented correctly */
|
/* Make sure the width/height are oriented correctly */
|
||||||
if (UIKit_IsDisplayLandscape(displaydata->uiscreen) != (width > height)) {
|
if (UIKit_IsDisplayLandscape(displaydata->uiscreen) != (width > height)) {
|
||||||
|
@ -239,7 +234,7 @@ UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
|
||||||
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
|
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
|
||||||
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
|
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
|
||||||
SDL_uikitviewcontroller *viewcontroller = windowdata->viewcontroller;
|
SDL_uikitviewcontroller *viewcontroller = windowdata->viewcontroller;
|
||||||
CGRect bounds;
|
CGRect frame;
|
||||||
|
|
||||||
if (fullscreen || (window->flags & SDL_WINDOW_BORDERLESS)) {
|
if (fullscreen || (window->flags & SDL_WINDOW_BORDERLESS)) {
|
||||||
[UIApplication sharedApplication].statusBarHidden = YES;
|
[UIApplication sharedApplication].statusBarHidden = YES;
|
||||||
|
@ -252,20 +247,15 @@ UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
|
||||||
[viewcontroller setNeedsStatusBarAppearanceUpdate];
|
[viewcontroller setNeedsStatusBarAppearanceUpdate];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullscreen || (window->flags & SDL_WINDOW_BORDERLESS)) {
|
|
||||||
bounds = [displaydata->uiscreen bounds];
|
|
||||||
} else {
|
|
||||||
bounds = [displaydata->uiscreen applicationFrame];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Update the view's frame to account for the status bar change. */
|
/* Update the view's frame to account for the status bar change. */
|
||||||
windowdata->view.frame = bounds;
|
frame = UIKit_ComputeViewFrame(window, displaydata->uiscreen);
|
||||||
|
windowdata->view.frame = frame;
|
||||||
[windowdata->view setNeedsLayout];
|
[windowdata->view setNeedsLayout];
|
||||||
[windowdata->view layoutIfNeeded];
|
[windowdata->view layoutIfNeeded];
|
||||||
|
|
||||||
/* Get frame dimensions */
|
/* Get frame dimensions */
|
||||||
int width = (int) bounds.size.width;
|
int width = (int) frame.size.width;
|
||||||
int height = (int) bounds.size.height;
|
int height = (int) frame.size.height;
|
||||||
|
|
||||||
/* We can pick either width or height here and we'll rotate the
|
/* We can pick either width or height here and we'll rotate the
|
||||||
screen to match, so we pick the closest to what we wanted.
|
screen to match, so we pick the closest to what we wanted.
|
||||||
|
|
Loading…
Reference in New Issue