comparison src/video/cocoa/SDL_cocoamodes.m @ 3500:4b594623401b

Work in progress on multi-display support: * Added display parameter to many internal functions so video modes can be set on displays that aren't the public current one. * The fullscreen mode is associated with fullscreen windows - not displays, so different windows more naturally have a mode associated with them based on their width and height. It's no longer necessary to specify a fullscreen mode, a default one will be picked automatically for fullscreen windows.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 01 Dec 2009 05:57:15 +0000
parents 00cace2d9080
children 919d88c202cf
comparison
equal deleted inserted replaced
3499:4cf8a1423d57 3500:4b594623401b
188 } 188 }
189 189
190 static void 190 static void
191 AddDisplayMode(const void *moderef, void *context) 191 AddDisplayMode(const void *moderef, void *context)
192 { 192 {
193 SDL_VideoDevice *_this = (SDL_VideoDevice *) context; 193 SDL_VideoDisplay *display = (SDL_VideoDisplay *) context;
194 SDL_DisplayMode mode; 194 SDL_DisplayMode mode;
195 195
196 if (GetDisplayMode(moderef, &mode)) { 196 if (GetDisplayMode(moderef, &mode)) {
197 SDL_AddDisplayMode(_this->current_display, &mode); 197 SDL_AddDisplayMode(display, &mode);
198 } 198 }
199 } 199 }
200 200
201 void 201 void
202 Cocoa_GetDisplayModes(_THIS) 202 Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
203 { 203 {
204 SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; 204 SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
205 CFArrayRef modes; 205 CFArrayRef modes;
206 CFRange range; 206 CFRange range;
207 207
208 modes = CGDisplayAvailableModes(data->display); 208 modes = CGDisplayAvailableModes(data->display);
209 if (!modes) { 209 if (!modes) {
210 return; 210 return;
211 } 211 }
212 range.location = 0; 212 range.location = 0;
213 range.length = CFArrayGetCount(modes); 213 range.length = CFArrayGetCount(modes);
214 CFArrayApplyFunction(modes, range, AddDisplayMode, _this); 214 CFArrayApplyFunction(modes, range, AddDisplayMode, display);
215 } 215 }
216 216
217 int 217 int
218 Cocoa_SetDisplayMode(_THIS, SDL_DisplayMode * mode) 218 Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
219 { 219 {
220 SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; 220 SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
221 SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata; 221 SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
222 CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken; 222 CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
223 CGError result; 223 CGError result;
224 224
225 /* Fade to black to hide resolution-switching flicker */ 225 /* Fade to black to hide resolution-switching flicker */
277 } 277 }
278 278
279 void 279 void
280 Cocoa_QuitModes(_THIS) 280 Cocoa_QuitModes(_THIS)
281 { 281 {
282 int i, saved_display; 282 int i;
283 283
284 saved_display = _this->current_display;
285 for (i = 0; i < _this->num_displays; ++i) { 284 for (i = 0; i < _this->num_displays; ++i) {
286 SDL_VideoDisplay *display = &_this->displays[i]; 285 SDL_VideoDisplay *display = &_this->displays[i];
287 286
288 if (display->current_mode.driverdata != display->desktop_mode.driverdata) { 287 if (display->current_mode.driverdata != display->desktop_mode.driverdata) {
289 _this->current_display = i; 288 Cocoa_SetDisplayMode(_this, display, &display->desktop_mode);
290 Cocoa_SetDisplayMode(_this, &display->desktop_mode);
291 } 289 }
292 } 290 }
293 CGReleaseAllDisplays(); 291 CGReleaseAllDisplays();
294 ShowMenuBar(); 292 ShowMenuBar();
295
296 _this->current_display = saved_display;
297 } 293 }
298 294
299 /* vi: set ts=4 sw=4 expandtab: */ 295 /* vi: set ts=4 sw=4 expandtab: */