comparison src/video/cocoa/SDL_cocoamodes.m @ 3505:a1bf34bc2a58

Ensure that the main display is picked up first
author Sam Lantinga <slouken@libsdl.org>
date Tue, 01 Dec 2009 10:41:58 +0000
parents 919d88c202cf
children 58cbfa81317a
comparison
equal deleted inserted replaced
3504:919d88c202cf 3505:a1bf34bc2a58
137 Cocoa_InitModes(_THIS) 137 Cocoa_InitModes(_THIS)
138 { 138 {
139 CGDisplayErr result; 139 CGDisplayErr result;
140 CGDirectDisplayID *displays; 140 CGDirectDisplayID *displays;
141 CGDisplayCount numDisplays; 141 CGDisplayCount numDisplays;
142 int i; 142 int pass, i;
143 143
144 result = CGGetOnlineDisplayList(0, NULL, &numDisplays); 144 result = CGGetOnlineDisplayList(0, NULL, &numDisplays);
145 if (result != kCGErrorSuccess) { 145 if (result != kCGErrorSuccess) {
146 CG_SetError("CGGetOnlineDisplayList()", result); 146 CG_SetError("CGGetOnlineDisplayList()", result);
147 return; 147 return;
152 CG_SetError("CGGetOnlineDisplayList()", result); 152 CG_SetError("CGGetOnlineDisplayList()", result);
153 SDL_stack_free(displays); 153 SDL_stack_free(displays);
154 return; 154 return;
155 } 155 }
156 156
157 for (i = 0; i < numDisplays; ++i) { 157 /* Pick up the primary display in the first pass, then get the rest */
158 SDL_VideoDisplay display; 158 for (pass = 0; pass < 2; ++pass) {
159 SDL_DisplayData *displaydata; 159 for (i = 0; i < numDisplays; ++i) {
160 SDL_DisplayMode mode; 160 SDL_VideoDisplay display;
161 CFDictionaryRef moderef; 161 SDL_DisplayData *displaydata;
162 162 SDL_DisplayMode mode;
163 if (CGDisplayMirrorsDisplay(displays[i]) != kCGNullDirectDisplay) { 163 CFDictionaryRef moderef;
164 continue; 164
165 if (pass == 0) {
166 if (!CGDisplayIsMain(displays[i])) {
167 continue;
168 }
169 } else {
170 if (CGDisplayIsMain(displays[i])) {
171 continue;
172 }
173 }
174
175 if (CGDisplayMirrorsDisplay(displays[i]) != kCGNullDirectDisplay) {
176 continue;
177 }
178 moderef = CGDisplayCurrentMode(displays[i]);
179 if (!moderef) {
180 continue;
181 }
182
183 displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
184 if (!displaydata) {
185 continue;
186 }
187 displaydata->display = displays[i];
188
189 SDL_zero(display);
190 if (!GetDisplayMode (moderef, &mode)) {
191 SDL_free(displaydata);
192 continue;
193 }
194 display.desktop_mode = mode;
195 display.current_mode = mode;
196 display.driverdata = displaydata;
197 SDL_AddVideoDisplay(&display);
165 } 198 }
166 moderef = CGDisplayCurrentMode(displays[i]);
167 if (!moderef) {
168 continue;
169 }
170
171 displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
172 if (!displaydata) {
173 continue;
174 }
175 displaydata->display = displays[i];
176
177 SDL_zero(display);
178 if (!GetDisplayMode (moderef, &mode)) {
179 SDL_free(displaydata);
180 continue;
181 }
182 display.desktop_mode = mode;
183 display.current_mode = mode;
184 display.driverdata = displaydata;
185 SDL_AddVideoDisplay(&display);
186 } 199 }
187 SDL_stack_free(displays); 200 SDL_stack_free(displays);
188 } 201 }
189 202
190 static void 203 static void