annotate src/video/cocoa/SDL_cocoamodes.m @ 2123:9a48d1a6fbec

Merged r3075:3076 from branches/SDL-1.2: Careful with __inline__ #define.
author Ryan C. Gordon <icculus@icculus.org>
date Fri, 15 Jun 2007 07:21:01 +0000
parents 81255f93dfcd
children e57a883ffa86
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
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
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
1973
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
26 /*
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
27 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
28 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
29 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
30 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
31 main screen).
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
32 */
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
33 @interface NSScreen (NSScreenAccess)
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
34 - (void) setFrame:(NSRect)frame;
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
35 @end
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
36
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
37 @implementation NSScreen (NSScreenAccess)
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
38 - (void) setFrame:(NSRect)frame;
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
39 {
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
40 _frame = frame;
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
41 }
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
42 @end
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
43
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
44 static void
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
45 CG_SetError(const char *prefix, CGDisplayErr result)
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
46 {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
47 const char *error;
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 switch (result) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
50 case kCGErrorFailure:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
51 error = "kCGErrorFailure";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
52 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
53 case kCGErrorIllegalArgument:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
54 error = "kCGErrorIllegalArgument";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
55 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
56 case kCGErrorInvalidConnection:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
57 error = "kCGErrorInvalidConnection";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
58 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
59 case kCGErrorInvalidContext:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
60 error = "kCGErrorInvalidContext";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
61 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
62 case kCGErrorCannotComplete:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
63 error = "kCGErrorCannotComplete";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
64 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
65 case kCGErrorNameTooLong:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
66 error = "kCGErrorNameTooLong";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
67 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
68 case kCGErrorNotImplemented:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
69 error = "kCGErrorNotImplemented";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
70 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
71 case kCGErrorRangeCheck:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
72 error = "kCGErrorRangeCheck";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
73 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
74 case kCGErrorTypeCheck:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
75 error = "kCGErrorTypeCheck";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
76 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
77 case kCGErrorNoCurrentPoint:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
78 error = "kCGErrorNoCurrentPoint";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
79 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
80 case kCGErrorInvalidOperation:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
81 error = "kCGErrorInvalidOperation";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
82 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
83 case kCGErrorNoneAvailable:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
84 error = "kCGErrorNoneAvailable";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
85 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
86 default:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
87 error = "Unknown Error";
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
88 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
89 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
90 SDL_SetError("%s: %s", prefix, error);
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
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
93 static SDL_bool
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
94 GetDisplayMode(CFDictionaryRef moderef, SDL_DisplayMode *mode)
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
95 {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
96 SDL_DisplayModeData *data;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
97 CFNumberRef number;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
98 long width, height, bpp, refreshRate;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
99
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
100 data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data));
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
101 if (!data) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
102 return SDL_FALSE;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
103 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
104 data->moderef = moderef;
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 number = CFDictionaryGetValue(moderef, kCGDisplayWidth);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
107 CFNumberGetValue(number, kCFNumberLongType, &width);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
108 number = CFDictionaryGetValue(moderef, kCGDisplayHeight);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
109 CFNumberGetValue(number, kCFNumberLongType, &height);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
110 number = CFDictionaryGetValue(moderef, kCGDisplayBitsPerPixel);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
111 CFNumberGetValue(number, kCFNumberLongType, &bpp);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
112 number = CFDictionaryGetValue(moderef, kCGDisplayRefreshRate);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
113 CFNumberGetValue(number, kCFNumberLongType, &refreshRate);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
114
1969
5d3724f64f2b Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents: 1934
diff changeset
115 mode->format = SDL_PIXELFORMAT_UNKNOWN;
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
116 switch (bpp) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
117 case 8:
1969
5d3724f64f2b Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents: 1934
diff changeset
118 mode->format = SDL_PIXELFORMAT_INDEX8;
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
119 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
120 case 16:
1969
5d3724f64f2b Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents: 1934
diff changeset
121 mode->format = SDL_PIXELFORMAT_RGB555;
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
122 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
123 case 32:
1969
5d3724f64f2b Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents: 1934
diff changeset
124 mode->format = SDL_PIXELFORMAT_RGB888;
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
125 break;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
126 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
127 mode->w = width;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
128 mode->h = height;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
129 mode->refresh_rate = refreshRate;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
130 mode->driverdata = data;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
131 return SDL_TRUE;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
132 }
1931
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 void
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 Cocoa_InitModes(_THIS)
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 {
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
137 CGDisplayErr result;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
138 CGDirectDisplayID *displays;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
139 CGDisplayCount numDisplays;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
140 int i;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
141
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
142 result = CGGetOnlineDisplayList(0, NULL, &numDisplays);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
143 if (result != kCGErrorSuccess) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
144 CG_SetError("CGGetOnlineDisplayList()", result);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
145 return;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
146 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
147 displays = SDL_stack_alloc(CGDirectDisplayID, numDisplays);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
148 result = CGGetOnlineDisplayList(numDisplays, displays, &numDisplays);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
149 if (result != kCGErrorSuccess) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
150 CG_SetError("CGGetOnlineDisplayList()", result);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
151 SDL_stack_free(displays);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
152 return;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
153 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
154
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
155 for (i = 0; i < numDisplays; ++i) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
156 SDL_VideoDisplay display;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
157 SDL_DisplayData *displaydata;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
158 SDL_DisplayMode mode;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
159 CFDictionaryRef moderef;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
160
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
161 if (CGDisplayIsInMirrorSet(displays[i])) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
162 continue;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
163 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
164 moderef = CGDisplayCurrentMode(displays[i]);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
165 if (!moderef) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
166 continue;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
167 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
168
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
169 displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
170 if (!displaydata) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
171 continue;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
172 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
173 displaydata->display = displays[i];
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 SDL_zero(display);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
176 if (!GetDisplayMode (moderef, &mode)) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
177 SDL_free(displaydata);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
178 continue;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
179 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
180 display.desktop_mode = mode;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
181 display.current_mode = mode;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
182 display.driverdata = displaydata;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
183 SDL_AddVideoDisplay(&display);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
184 }
1973
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
185 SDL_stack_free(displays);
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
186 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
187
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
188 static void
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
189 AddDisplayMode(const void *moderef, void *context)
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
190 {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
191 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
192 SDL_DisplayMode mode;
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
194 if (GetDisplayMode(moderef, &mode)) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
195 SDL_AddDisplayMode(_this->current_display, &mode);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
196 }
1931
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 }
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 void
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 Cocoa_GetDisplayModes(_THIS)
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 {
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
202 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
203 CFArrayRef modes;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
204 CFRange range;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
205
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
206 modes = CGDisplayAvailableModes(data->display);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
207 if (!modes) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
208 return;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
209 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
210 range.location = 0;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
211 range.length = CFArrayGetCount(modes);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
212 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
213 }
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 int
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 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
217 {
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
218 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
219 SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
220 CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
221 CGError result;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
222
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
223 /* 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
224 if (CGAcquireDisplayFadeReservation(5, &fade_token) == kCGErrorSuccess) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
225 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
226 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
227
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
228 /* 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
229 result = CGDisplayCapture(displaydata->display);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
230 if (result != kCGErrorSuccess) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
231 CG_SetError("CGDisplayCapture()", result);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
232 goto ERR_NO_CAPTURE;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
233 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
234
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
235 /* Do the physical switch */
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
236 result = CGDisplaySwitchToMode(displaydata->display, data->moderef);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
237 if (result != kCGErrorSuccess) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
238 CG_SetError("CGDisplaySwitchToMode()", result);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
239 goto ERR_NO_SWITCH;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
240 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
241
1973
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
242 /* 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
243 HideMenuBar();
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
244
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
245 /* Fade in again (asynchronously) */
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
246 if (fade_token != kCGDisplayFadeReservationInvalidToken) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
247 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
248 CGReleaseDisplayFadeReservation(fade_token);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
249 }
1973
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
250
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
251 /*
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
252 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
253 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
254 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
255 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
256 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
257 */
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
258 [[NSScreen mainScreen] setFrame:NSMakeRect(0,0,mode->w,mode->h)];
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
259
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
260 return 0;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
261
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
262 /* 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
263 ERR_NO_SWITCH:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
264 CGDisplayRelease(displaydata->display);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
265 ERR_NO_CAPTURE:
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
266 if (fade_token != kCGDisplayFadeReservationInvalidToken) {
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
267 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
268 CGReleaseDisplayFadeReservation(fade_token);
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
269 }
1931
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 return -1;
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 }
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 void
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 Cocoa_QuitModes(_THIS)
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 {
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
276 int i, saved_display;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
277
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
278 saved_display = _this->current_display;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
279 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
280 SDL_VideoDisplay *display = &_this->displays[i];
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 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
283 _this->current_display = i;
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
284 Cocoa_SetDisplayMode(_this, &display->desktop_mode);
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 }
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
287 CGReleaseAllDisplays();
1973
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
288 ShowMenuBar();
81255f93dfcd Fixed fullscreen modes with Cocoa video driver.
Sam Lantinga <slouken@libsdl.org>
parents: 1969
diff changeset
289
1934
70139af5ac27 Implemented Mac OS X video mode selection.
Sam Lantinga <slouken@libsdl.org>
parents: 1931
diff changeset
290 _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
291 }
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292
103c6fec2a60 The Mac OS X Cocoa video driver is under construction...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 /* vi: set ts=4 sw=4 expandtab: */