diff src/video/uikit/SDL_uikitappdelegate.m @ 4446:8b03a20b320f

Much improved multi-display support for iPad. Fixes most issues and limitations, I think.
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 02 May 2010 05:08:12 -0400
parents 64ce267332c6
children 2bb1bfeee9e2
line wrap: on
line diff
--- a/src/video/uikit/SDL_uikitappdelegate.m	Sat May 01 13:50:56 2010 -0400
+++ b/src/video/uikit/SDL_uikitappdelegate.m	Sun May 02 05:08:12 2010 -0400
@@ -20,6 +20,8 @@
  slouken@libsdl.org
 */
 
+#import "../SDL_sysvideo.h"
+
 #import "SDL_uikitappdelegate.h"
 #import "SDL_uikitopenglview.h"
 #import "SDL_events_c.h"
@@ -55,9 +57,6 @@
 
 @implementation SDLUIKitDelegate
 
-@synthesize window;
-@synthesize uiwindow;
-
 /* convenience method */
 +(SDLUIKitDelegate *)sharedAppDelegate {
 	/* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */
@@ -66,8 +65,6 @@
 
 - (id)init {
 	self = [super init];
-	window = NULL;
-	uiwindow = nil;
 	return self;
 }
 
@@ -106,21 +103,42 @@
 
 - (void) applicationWillResignActive:(UIApplication*)application
 {
-//	NSLog(@"%@", NSStringFromSelector(_cmd));
-	SDL_SendWindowEvent(self.window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
+    //NSLog(@"%@", NSStringFromSelector(_cmd));
+
+    // Send every window on every screen a MINIMIZED event.
+    SDL_VideoDevice *_this = SDL_GetVideoDevice();
+    if (!_this) {
+        return;
+    }
+
+    int i;
+    for (i = 0; i < _this->num_displays; i++) {
+        const SDL_VideoDisplay *display = &_this->displays[i];
+        SDL_Window *window;
+        for (window = display->windows; window != nil; window = window->next) {
+            SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
+        }
+    }
 }
 
 - (void) applicationDidBecomeActive:(UIApplication*)application
 {
-//	NSLog(@"%@", NSStringFromSelector(_cmd));
-	SDL_SendWindowEvent(self.window, SDL_WINDOWEVENT_RESTORED, 0, 0);
-}
+    //NSLog(@"%@", NSStringFromSelector(_cmd));
 
+    // Send every window on every screen a RESTORED event.
+    SDL_VideoDevice *_this = SDL_GetVideoDevice();
+    if (!_this) {
+        return;
+    }
 
-
--(void)dealloc {
-	[uiwindow release];
-	[super dealloc];
+    int i;
+    for (i = 0; i < _this->num_displays; i++) {
+        const SDL_VideoDisplay *display = &_this->displays[i];
+        SDL_Window *window;
+        for (window = display->windows; window != nil; window = window->next) {
+            SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
+        }
+    }
 }
 
 @end