Do not use UIScreenMode to add a iOS display, always use the boundary
authorKees Bakker <kees@ijzerbout.nl>
Sun, 09 Oct 2011 22:00:20 +0200
changeset 6013b253cc3c4276
parent 6012 0291eb4caec4
child 6014 7a8b72b88d86
Do not use UIScreenMode to add a iOS display, always use the boundary

This solves the problem that on iPad you would get 1024x768 instead
of 768x1024 when calling SDL_GetDesktopDisplayMode(0, &mode)
See Apple's doc for UIScreenMode where is says:
"Most developers should never need to use the information provided
by this class and should simply use the bounds provided by the
UIScreen object for their drawing space."
src/video/uikit/SDL_uikitvideo.m
     1.1 --- a/src/video/uikit/SDL_uikitvideo.m	Sat Oct 08 12:45:10 2011 +0200
     1.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Sun Oct 09 22:00:20 2011 +0200
     1.3 @@ -199,21 +199,23 @@
     1.4      if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
     1.5          SDL_UIKit_supports_multiple_displays = YES;
     1.6  
     1.7 +    // Add the main screen.
     1.8 +    UIScreen *uiscreen = [UIScreen mainScreen];
     1.9 +    UIScreenMode *uiscreenmode = [uiscreen currentMode];
    1.10 +    const CGSize size = [uiscreen bounds].size;
    1.11 +    UIKit_AddDisplay(uiscreen, uiscreenmode, (int)size.width, (int)size.height);
    1.12 +
    1.13      // If this is iPhoneOS < 3.2, all devices are one screen, 320x480 pixels.
    1.14      //  The iPad added both a larger main screen and the ability to use
    1.15 -    //  external displays.
    1.16 -    if (!SDL_UIKit_supports_multiple_displays) {
    1.17 -        // Just give 'em the whole main screen.
    1.18 -        UIScreen *uiscreen = [UIScreen mainScreen];
    1.19 -        UIScreenMode *uiscreenmode = [uiscreen currentMode];
    1.20 -        const CGSize size = [uiscreen bounds].size;
    1.21 -        UIKit_AddDisplay(uiscreen, uiscreenmode, (int)size.width, (int)size.height);
    1.22 -    } else {
    1.23 +    //  external displays. So, add the other displays (screens in UI speak).
    1.24 +    if (SDL_UIKit_supports_multiple_displays) {
    1.25          for (UIScreen *uiscreen in [UIScreen screens]) {
    1.26 -            // the main screen is the first element in the array.
    1.27 -            UIScreenMode *uiscreenmode = [uiscreen currentMode];
    1.28 -            const CGSize size = [[uiscreen currentMode] size];
    1.29 -            UIKit_AddDisplay(uiscreen, uiscreenmode, (int)size.width, (int)size.height);
    1.30 +            // Only add the other screens
    1.31 +            if (uiscreen != [UIScreen mainScreen]) {
    1.32 +                UIScreenMode *uiscreenmode = [uiscreen currentMode];
    1.33 +                const CGSize size = [uiscreen bounds].size;
    1.34 +                UIKit_AddDisplay(uiscreen, uiscreenmode, (int)size.width, (int)size.height);
    1.35 +            }
    1.36          }
    1.37      }
    1.38