Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Updated support for external video output on the iPad
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Sep 29, 2012
1 parent 49b6b5c commit 7f2fe06
Showing 1 changed file with 36 additions and 38 deletions.
74 changes: 36 additions & 38 deletions src/video/uikit/SDL_uikitwindow.m
Expand Up @@ -75,26 +75,31 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
/* Get frame dimensions in pixels */
int width = (int)(bounds.size.width * displaymodedata->scale);
int height = (int)(bounds.size.height * displaymodedata->scale);

/* 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.
*/
if (window->w >= window->h) {
if (width > height) {
window->w = width;
window->h = height;

if ([UIScreen mainScreen] == displaydata->uiscreen) {
/* 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.
*/
if (window->w >= window->h) {
if (width > height) {
window->w = width;
window->h = height;
} else {
window->w = height;
window->h = width;
}
} else {
window->w = height;
window->h = width;
if (width > height) {
window->w = height;
window->h = width;
} else {
window->w = width;
window->h = height;
}
}
} else {
if (width > height) {
window->w = height;
window->h = width;
} else {
window->w = width;
window->h = height;
}
window->w = width;
window->h = height;
}
}

Expand All @@ -106,28 +111,28 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
// SDL_WINDOW_BORDERLESS controls whether status bar is hidden.
// This is only set if the window is on the main screen. Other screens
// just force the window to have the borderless flag.
if ([UIScreen mainScreen] != displaydata->uiscreen) {
window->flags &= ~SDL_WINDOW_RESIZABLE; // window is NEVER resizeable
window->flags &= ~SDL_WINDOW_INPUT_FOCUS; // never has input focus
window->flags |= SDL_WINDOW_BORDERLESS; // never has a status bar.
} else {
if ([UIScreen mainScreen] == displaydata->uiscreen) {
window->flags |= SDL_WINDOW_INPUT_FOCUS; // always has input focus

if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
[UIApplication sharedApplication].statusBarHidden = YES;
} else {
[UIApplication sharedApplication].statusBarHidden = NO;
}

// The View Controller will handle rotating the view when the
// device orientation changes. This will trigger resize events, if
// appropriate.
SDL_uikitviewcontroller *controller;
controller = [SDL_uikitviewcontroller alloc];
data->viewcontroller = [controller initWithSDLWindow:window];
[data->viewcontroller setTitle:@"SDL App"]; // !!! FIXME: hook up SDL_SetWindowTitle()
} else {
window->flags &= ~SDL_WINDOW_RESIZABLE; // window is NEVER resizeable
window->flags &= ~SDL_WINDOW_INPUT_FOCUS; // never has input focus
window->flags |= SDL_WINDOW_BORDERLESS; // never has a status bar.
}

// The View Controller will handle rotating the view when the
// device orientation changes. This will trigger resize events, if
// appropriate.
SDL_uikitviewcontroller *controller;
controller = [SDL_uikitviewcontroller alloc];
data->viewcontroller = [controller initWithSDLWindow:window];
[data->viewcontroller setTitle:@"SDL App"]; // !!! FIXME: hook up SDL_SetWindowTitle()

return 0;
}

Expand All @@ -147,13 +152,6 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
return -1;
}

// Non-mainscreen windows must be force to borderless, as there's no
// status bar there, and we want to get the right dimensions later in
// this function.
if (external) {
window->flags |= SDL_WINDOW_BORDERLESS;
}

// If monitor has a resolution of 0x0 (hasn't been explicitly set by the
// user, so it's in standby), try to force the display to a resolution
// that most closely matches the desired window size.
Expand Down

0 comments on commit 7f2fe06

Please sign in to comment.