Updated support for external video output on the iPad

This commit is contained in:
Sam Lantinga 2012-09-29 00:17:34 -07:00
parent 72cdf43759
commit e4c54831a2

View file

@ -76,6 +76,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
int width = (int)(bounds.size.width * displaymodedata->scale); int width = (int)(bounds.size.width * displaymodedata->scale);
int height = (int)(bounds.size.height * displaymodedata->scale); int height = (int)(bounds.size.height * displaymodedata->scale);
if ([UIScreen mainScreen] == displaydata->uiscreen) {
/* 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.
*/ */
@ -96,6 +97,10 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
window->h = height; window->h = height;
} }
} }
} else {
window->w = width;
window->h = height;
}
} }
window->driverdata = data; window->driverdata = data;
@ -106,11 +111,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
// SDL_WINDOW_BORDERLESS controls whether status bar is hidden. // SDL_WINDOW_BORDERLESS controls whether status bar is hidden.
// This is only set if the window is on the main screen. Other screens // This is only set if the window is on the main screen. Other screens
// just force the window to have the borderless flag. // just force the window to have the borderless flag.
if ([UIScreen mainScreen] != displaydata->uiscreen) { 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 {
window->flags |= SDL_WINDOW_INPUT_FOCUS; // always has input focus window->flags |= SDL_WINDOW_INPUT_FOCUS; // always has input focus
if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) { if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
@ -118,6 +119,11 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
} else { } else {
[UIApplication sharedApplication].statusBarHidden = NO; [UIApplication sharedApplication].statusBarHidden = NO;
} }
} 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 // The View Controller will handle rotating the view when the
// device orientation changes. This will trigger resize events, if // device orientation changes. This will trigger resize events, if
@ -126,7 +132,6 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
controller = [SDL_uikitviewcontroller alloc]; controller = [SDL_uikitviewcontroller alloc];
data->viewcontroller = [controller initWithSDLWindow:window]; data->viewcontroller = [controller initWithSDLWindow:window];
[data->viewcontroller setTitle:@"SDL App"]; // !!! FIXME: hook up SDL_SetWindowTitle() [data->viewcontroller setTitle:@"SDL App"]; // !!! FIXME: hook up SDL_SetWindowTitle()
}
return 0; return 0;
} }
@ -147,13 +152,6 @@ UIKit_CreateWindow(_THIS, SDL_Window *window)
return -1; 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 // 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 // user, so it's in standby), try to force the display to a resolution
// that most closely matches the desired window size. // that most closely matches the desired window size.