annotate src/video/cocoa/SDL_cocoamodes.m @ 3254:1a8c9a6752e5

Upgraded solution to Visual Studio 2008 and added 64-bit target
author Sam Lantinga <slouken@libsdl.org>
date Sun, 06 Sep 2009 04:40:29 +0000
parents cde30895105d
children 00cace2d9080
rev   line source
1931
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
2859
99210400e8b9 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 2237
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
1931
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #include "SDL_cocoavideo.h"
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25
3248
cde30895105d Added 64-bit architectures to the fat build script
Sam Lantinga <slouken@libsdl.org>
parents: 3246
diff changeset
26 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
1973
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
27 /*
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
28 Add methods to get at private members of NSScreen.
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
29 Since there is a bug in Apple's screen switching code
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
30 that does not update this variable when switching
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
31 to fullscreen, we'll set it manually (but only for the
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
32 main screen).
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
33 */
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
34 @interface NSScreen (NSScreenAccess)
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
35 - (void) setFrame:(NSRect)frame;
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
36 @end
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
37
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
38 @implementation NSScreen (NSScreenAccess)
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
39 - (void) setFrame:(NSRect)frame;
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
40 {
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
41 _frame = frame;
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
42 }
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
43 @end
3246
c843261f74a4 From: Jjgod Jiang <gzjjgod@gmail.com>
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
44 #endif
1973
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
45
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
46 static void
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
47 CG_SetError(const char *prefix, CGDisplayErr result)
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
48 {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
49 const char *error;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
50
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
51 switch (result) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
52 case kCGErrorFailure:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
53 error = "kCGErrorFailure";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
54 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
55 case kCGErrorIllegalArgument:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
56 error = "kCGErrorIllegalArgument";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
57 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
58 case kCGErrorInvalidConnection:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
59 error = "kCGErrorInvalidConnection";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
60 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
61 case kCGErrorInvalidContext:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
62 error = "kCGErrorInvalidContext";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
63 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
64 case kCGErrorCannotComplete:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
65 error = "kCGErrorCannotComplete";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
66 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
67 case kCGErrorNameTooLong:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
68 error = "kCGErrorNameTooLong";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
69 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
70 case kCGErrorNotImplemented:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
71 error = "kCGErrorNotImplemented";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
72 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
73 case kCGErrorRangeCheck:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
74 error = "kCGErrorRangeCheck";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
75 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
76 case kCGErrorTypeCheck:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
77 error = "kCGErrorTypeCheck";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
78 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
79 case kCGErrorNoCurrentPoint:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
80 error = "kCGErrorNoCurrentPoint";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
81 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
82 case kCGErrorInvalidOperation:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
83 error = "kCGErrorInvalidOperation";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
84 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
85 case kCGErrorNoneAvailable:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
86 error = "kCGErrorNoneAvailable";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
87 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
88 default:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
89 error = "Unknown Error";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
90 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
91 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
92 SDL_SetError("%s: %s", prefix, error);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
93 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
94
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
95 static SDL_bool
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
96 GetDisplayMode(CFDictionaryRef moderef, SDL_DisplayMode *mode)
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
97 {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
98 SDL_DisplayModeData *data;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
99 CFNumberRef number;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
100 long width, height, bpp, refreshRate;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
101
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
102 data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data));
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
103 if (!data) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
104 return SDL_FALSE;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
105 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
106 data->moderef = moderef;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
107
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
108 number = CFDictionaryGetValue(moderef, kCGDisplayWidth);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
109 CFNumberGetValue(number, kCFNumberLongType, &width);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
110 number = CFDictionaryGetValue(moderef, kCGDisplayHeight);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
111 CFNumberGetValue(number, kCFNumberLongType, &height);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
112 number = CFDictionaryGetValue(moderef, kCGDisplayBitsPerPixel);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
113 CFNumberGetValue(number, kCFNumberLongType, &bpp);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
114 number = CFDictionaryGetValue(moderef, kCGDisplayRefreshRate);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
115 CFNumberGetValue(number, kCFNumberLongType, &refreshRate);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
116
1969
5d3724f64f2b Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents: 1934
diff changeset
117 mode->format = SDL_PIXELFORMAT_UNKNOWN;
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
118 switch (bpp) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
119 case 8:
1969
5d3724f64f2b Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents: 1934
diff changeset
120 mode->format = SDL_PIXELFORMAT_INDEX8;
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
121 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
122 case 16:
2237
e57a883ffa86 Advertise the most efficient format for the screen. Of course SDL code needs
Sam Lantinga <slouken@libsdl.org>
parents: 1973
diff changeset
123 mode->format = SDL_PIXELFORMAT_ARGB1555;
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
124 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
125 case 32:
2237
e57a883ffa86 Advertise the most efficient format for the screen. Of course SDL code needs
Sam Lantinga <slouken@libsdl.org>
parents: 1973
diff changeset
126 mode->format = SDL_PIXELFORMAT_ARGB8888;
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
127 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
128 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
129 mode->w = width;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
130 mode->h = height;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
131 mode->refresh_rate = refreshRate;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
132 mode->driverdata = data;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
133 return SDL_TRUE;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
134 }
1931
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 void
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 Cocoa_InitModes(_THIS)
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 {
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
139 CGDisplayErr result;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
140 CGDirectDisplayID *displays;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
141 CGDisplayCount numDisplays;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
142 int i;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
143
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
144 result = CGGetOnlineDisplayList(0, NULL, &numDisplays);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
145 if (result != kCGErrorSuccess) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
146 CG_SetError("CGGetOnlineDisplayList()", result);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
147 return;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
148 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
149 displays = SDL_stack_alloc(CGDirectDisplayID, numDisplays);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
150 result = CGGetOnlineDisplayList(numDisplays, displays, &numDisplays);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
151 if (result != kCGErrorSuccess) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
152 CG_SetError("CGGetOnlineDisplayList()", result);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
153 SDL_stack_free(displays);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
154 return;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
155 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
156
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
157 for (i = 0; i < numDisplays; ++i) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
158 SDL_VideoDisplay display;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
159 SDL_DisplayData *displaydata;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
160 SDL_DisplayMode mode;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
161 CFDictionaryRef moderef;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
162
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
163 if (CGDisplayIsInMirrorSet(displays[i])) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
164 continue;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
165 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
166 moderef = CGDisplayCurrentMode(displays[i]);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
167 if (!moderef) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
168 continue;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
169 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
170
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
171 displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
172 if (!displaydata) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
173 continue;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
174 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
175 displaydata->display = displays[i];
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
176
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
177 SDL_zero(display);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
178 if (!GetDisplayMode (moderef, &mode)) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
179 SDL_free(displaydata);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
180 continue;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
181 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
182 display.desktop_mode = mode;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
183 display.current_mode = mode;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
184 display.driverdata = displaydata;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
185 SDL_AddVideoDisplay(&display);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
186 }
1973
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
187 SDL_stack_free(displays);
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
188 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
189
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
190 static void
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
191 AddDisplayMode(const void *moderef, void *context)
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
192 {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
193 SDL_VideoDevice *_this = (SDL_VideoDevice *) context;
1931
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 SDL_DisplayMode mode;
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
196 if (GetDisplayMode(moderef, &mode)) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
197 SDL_AddDisplayMode(_this->current_display, &mode);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
198 }
1931
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 }
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 void
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 Cocoa_GetDisplayModes(_THIS)
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 {
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
204 SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
205 CFArrayRef modes;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
206 CFRange range;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
207
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
208 modes = CGDisplayAvailableModes(data->display);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
209 if (!modes) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
210 return;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
211 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
212 range.location = 0;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
213 range.length = CFArrayGetCount(modes);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
214 CFArrayApplyFunction(modes, range, AddDisplayMode, _this);
1931
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 }
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 int
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 Cocoa_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 {
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
220 SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
221 SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
222 CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
223 CGError result;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
224
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
225 /* Fade to black to hide resolution-switching flicker */
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
226 if (CGAcquireDisplayFadeReservation(5, &fade_token) == kCGErrorSuccess) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
227 CGDisplayFade(fade_token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
228 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
229
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
230 /* Put up the blanking window (a window above all other windows) */
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
231 result = CGDisplayCapture(displaydata->display);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
232 if (result != kCGErrorSuccess) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
233 CG_SetError("CGDisplayCapture()", result);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
234 goto ERR_NO_CAPTURE;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
235 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
236
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
237 /* Do the physical switch */
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
238 result = CGDisplaySwitchToMode(displaydata->display, data->moderef);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
239 if (result != kCGErrorSuccess) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
240 CG_SetError("CGDisplaySwitchToMode()", result);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
241 goto ERR_NO_SWITCH;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
242 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
243
1973
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
244 /* Hide the menu bar so it doesn't intercept events */
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
245 HideMenuBar();
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
246
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
247 /* Fade in again (asynchronously) */
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
248 if (fade_token != kCGDisplayFadeReservationInvalidToken) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
249 CGDisplayFade(fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
250 CGReleaseDisplayFadeReservation(fade_token);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
251 }
1973
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
252
3248
cde30895105d Added 64-bit architectures to the fat build script
Sam Lantinga <slouken@libsdl.org>
parents: 3246
diff changeset
253 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
1973
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
254 /*
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
255 There is a bug in Cocoa where NSScreen doesn't synchronize
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
256 with CGDirectDisplay, so the main screen's frame is wrong.
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
257 As a result, coordinate translation produces incorrect results.
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
258 We can hack around this bug by setting the screen rect
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
259 ourselves. This hack should be removed if/when the bug is fixed.
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
260 */
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
261 [[NSScreen mainScreen] setFrame:NSMakeRect(0,0,mode->w,mode->h)];
3246
c843261f74a4 From: Jjgod Jiang <gzjjgod@gmail.com>
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
262 #endif
1973
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
263
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
264 return 0;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
265
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
266 /* Since the blanking window covers *all* windows (even force quit) correct recovery is crucial */
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
267 ERR_NO_SWITCH:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
268 CGDisplayRelease(displaydata->display);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
269 ERR_NO_CAPTURE:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
270 if (fade_token != kCGDisplayFadeReservationInvalidToken) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
271 CGDisplayFade (fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
272 CGReleaseDisplayFadeReservation(fade_token);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
273 }
1931
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 return -1;
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 }
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 void
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 Cocoa_QuitModes(_THIS)
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 {
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
280 int i, saved_display;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
281
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
282 saved_display = _this->current_display;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
283 for (i = 0; i < _this->num_displays; ++i) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
284 SDL_VideoDisplay *display = &_this->displays[i];
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
285
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
286 if (display->current_mode.driverdata != display->desktop_mode.driverdata) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
287 _this->current_display = i;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
288 Cocoa_SetDisplayMode(_this, &display->desktop_mode);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
289 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
290 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
291 CGReleaseAllDisplays();
1973
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
292 ShowMenuBar();
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
293
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
294 _this->current_display = saved_display;
1931
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 }
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 /* vi: set ts=4 sw=4 expandtab: */