Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Ensure that the main display is picked up first
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Dec 1, 2009
1 parent 7040de6 commit 3efbabe
Showing 1 changed file with 42 additions and 29 deletions.
71 changes: 42 additions & 29 deletions src/video/cocoa/SDL_cocoamodes.m
Expand Up @@ -139,7 +139,7 @@ - (void) setFrame:(NSRect)frame;
CGDisplayErr result;
CGDirectDisplayID *displays;
CGDisplayCount numDisplays;
int i;
int pass, i;

result = CGGetOnlineDisplayList(0, NULL, &numDisplays);
if (result != kCGErrorSuccess) {
Expand All @@ -154,35 +154,48 @@ - (void) setFrame:(NSRect)frame;
return;
}

for (i = 0; i < numDisplays; ++i) {
SDL_VideoDisplay display;
SDL_DisplayData *displaydata;
SDL_DisplayMode mode;
CFDictionaryRef moderef;

if (CGDisplayMirrorsDisplay(displays[i]) != kCGNullDirectDisplay) {
continue;
}
moderef = CGDisplayCurrentMode(displays[i]);
if (!moderef) {
continue;
}

displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
if (!displaydata) {
continue;
}
displaydata->display = displays[i];

SDL_zero(display);
if (!GetDisplayMode (moderef, &mode)) {
SDL_free(displaydata);
continue;
/* Pick up the primary display in the first pass, then get the rest */
for (pass = 0; pass < 2; ++pass) {
for (i = 0; i < numDisplays; ++i) {
SDL_VideoDisplay display;
SDL_DisplayData *displaydata;
SDL_DisplayMode mode;
CFDictionaryRef moderef;

if (pass == 0) {
if (!CGDisplayIsMain(displays[i])) {
continue;
}
} else {
if (CGDisplayIsMain(displays[i])) {
continue;
}
}

if (CGDisplayMirrorsDisplay(displays[i]) != kCGNullDirectDisplay) {
continue;
}
moderef = CGDisplayCurrentMode(displays[i]);
if (!moderef) {
continue;
}

displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
if (!displaydata) {
continue;
}
displaydata->display = displays[i];

SDL_zero(display);
if (!GetDisplayMode (moderef, &mode)) {
SDL_free(displaydata);
continue;
}
display.desktop_mode = mode;
display.current_mode = mode;
display.driverdata = displaydata;
SDL_AddVideoDisplay(&display);
}
display.desktop_mode = mode;
display.current_mode = mode;
display.driverdata = displaydata;
SDL_AddVideoDisplay(&display);
}
SDL_stack_free(displays);
}
Expand Down

0 comments on commit 3efbabe

Please sign in to comment.