Mercurial > sdl-ios-xcode
comparison 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 |
comparison
equal
deleted
inserted
replaced
4445:06becafcac89 | 4446:8b03a20b320f |
---|---|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
18 | 18 |
19 Sam Lantinga | 19 Sam Lantinga |
20 slouken@libsdl.org | 20 slouken@libsdl.org |
21 */ | 21 */ |
22 | |
23 #import "../SDL_sysvideo.h" | |
22 | 24 |
23 #import "SDL_uikitappdelegate.h" | 25 #import "SDL_uikitappdelegate.h" |
24 #import "SDL_uikitopenglview.h" | 26 #import "SDL_uikitopenglview.h" |
25 #import "SDL_events_c.h" | 27 #import "SDL_events_c.h" |
26 #import "jumphack.h" | 28 #import "jumphack.h" |
53 | 55 |
54 } | 56 } |
55 | 57 |
56 @implementation SDLUIKitDelegate | 58 @implementation SDLUIKitDelegate |
57 | 59 |
58 @synthesize window; | |
59 @synthesize uiwindow; | |
60 | |
61 /* convenience method */ | 60 /* convenience method */ |
62 +(SDLUIKitDelegate *)sharedAppDelegate { | 61 +(SDLUIKitDelegate *)sharedAppDelegate { |
63 /* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */ | 62 /* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */ |
64 return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate]; | 63 return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate]; |
65 } | 64 } |
66 | 65 |
67 - (id)init { | 66 - (id)init { |
68 self = [super init]; | 67 self = [super init]; |
69 window = NULL; | |
70 uiwindow = nil; | |
71 return self; | 68 return self; |
72 } | 69 } |
73 | 70 |
74 - (void)postFinishLaunch { | 71 - (void)postFinishLaunch { |
75 | 72 |
104 | 101 |
105 } | 102 } |
106 | 103 |
107 - (void) applicationWillResignActive:(UIApplication*)application | 104 - (void) applicationWillResignActive:(UIApplication*)application |
108 { | 105 { |
109 // NSLog(@"%@", NSStringFromSelector(_cmd)); | 106 //NSLog(@"%@", NSStringFromSelector(_cmd)); |
110 SDL_SendWindowEvent(self.window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); | 107 |
108 // Send every window on every screen a MINIMIZED event. | |
109 SDL_VideoDevice *_this = SDL_GetVideoDevice(); | |
110 if (!_this) { | |
111 return; | |
112 } | |
113 | |
114 int i; | |
115 for (i = 0; i < _this->num_displays; i++) { | |
116 const SDL_VideoDisplay *display = &_this->displays[i]; | |
117 SDL_Window *window; | |
118 for (window = display->windows; window != nil; window = window->next) { | |
119 SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); | |
120 } | |
121 } | |
111 } | 122 } |
112 | 123 |
113 - (void) applicationDidBecomeActive:(UIApplication*)application | 124 - (void) applicationDidBecomeActive:(UIApplication*)application |
114 { | 125 { |
115 // NSLog(@"%@", NSStringFromSelector(_cmd)); | 126 //NSLog(@"%@", NSStringFromSelector(_cmd)); |
116 SDL_SendWindowEvent(self.window, SDL_WINDOWEVENT_RESTORED, 0, 0); | |
117 } | |
118 | 127 |
128 // Send every window on every screen a RESTORED event. | |
129 SDL_VideoDevice *_this = SDL_GetVideoDevice(); | |
130 if (!_this) { | |
131 return; | |
132 } | |
119 | 133 |
120 | 134 int i; |
121 -(void)dealloc { | 135 for (i = 0; i < _this->num_displays; i++) { |
122 [uiwindow release]; | 136 const SDL_VideoDisplay *display = &_this->displays[i]; |
123 [super dealloc]; | 137 SDL_Window *window; |
138 for (window = display->windows; window != nil; window = window->next) { | |
139 SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0); | |
140 } | |
141 } | |
124 } | 142 } |
125 | 143 |
126 @end | 144 @end |