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 6013 b253cc3c4276
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
--- a/src/video/uikit/SDL_uikitvideo.m	Sat Oct 08 12:45:10 2011 +0200
+++ b/src/video/uikit/SDL_uikitvideo.m	Sun Oct 09 22:00:20 2011 +0200
@@ -199,21 +199,23 @@
     if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
         SDL_UIKit_supports_multiple_displays = YES;
 
+    // Add the main screen.
+    UIScreen *uiscreen = [UIScreen mainScreen];
+    UIScreenMode *uiscreenmode = [uiscreen currentMode];
+    const CGSize size = [uiscreen bounds].size;
+    UIKit_AddDisplay(uiscreen, uiscreenmode, (int)size.width, (int)size.height);
+
     // If this is iPhoneOS < 3.2, all devices are one screen, 320x480 pixels.
     //  The iPad added both a larger main screen and the ability to use
-    //  external displays.
-    if (!SDL_UIKit_supports_multiple_displays) {
-        // Just give 'em the whole main screen.
-        UIScreen *uiscreen = [UIScreen mainScreen];
-        UIScreenMode *uiscreenmode = [uiscreen currentMode];
-        const CGSize size = [uiscreen bounds].size;
-        UIKit_AddDisplay(uiscreen, uiscreenmode, (int)size.width, (int)size.height);
-    } else {
+    //  external displays. So, add the other displays (screens in UI speak).
+    if (SDL_UIKit_supports_multiple_displays) {
         for (UIScreen *uiscreen in [UIScreen screens]) {
-            // the main screen is the first element in the array.
-            UIScreenMode *uiscreenmode = [uiscreen currentMode];
-            const CGSize size = [[uiscreen currentMode] size];
-            UIKit_AddDisplay(uiscreen, uiscreenmode, (int)size.width, (int)size.height);
+            // Only add the other screens
+            if (uiscreen != [UIScreen mainScreen]) {
+                UIScreenMode *uiscreenmode = [uiscreen currentMode];
+                const CGSize size = [uiscreen bounds].size;
+                UIKit_AddDisplay(uiscreen, uiscreenmode, (int)size.width, (int)size.height);
+            }
         }
     }