mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 13:55:36 +00:00
macOS: Make sure the desktop's display mode is always in SDL's list of display modes.
This commit is contained in:
parent
616827ae64
commit
64ec4c3334
|
@ -340,29 +340,53 @@ void
|
|||
Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
||||
{
|
||||
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
|
||||
CFArrayRef modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
|
||||
|
||||
if (modes) {
|
||||
CVDisplayLinkRef link = NULL;
|
||||
const CFIndex count = CFArrayGetCount(modes);
|
||||
CFIndex i;
|
||||
CGDisplayModeRef desktopmoderef;
|
||||
SDL_DisplayMode desktopmode;
|
||||
CFArrayRef modes;
|
||||
|
||||
CVDisplayLinkCreateWithCGDisplay(data->display, &link);
|
||||
|
||||
desktopmoderef = CGDisplayCopyDisplayMode(data->display);
|
||||
|
||||
/* CopyAllDisplayModes won't always contain the desktop display mode (if
|
||||
* NULL is passed in) - for example on a retina 15" MBP, System Preferences
|
||||
* allows choosing 1920x1200 but it's not in the list. AddDisplayMode makes
|
||||
* sure there are no duplicates so it's safe to always add the desktop mode
|
||||
* even in cases where it is in the CopyAllDisplayModes list.
|
||||
*/
|
||||
if (desktopmoderef && GetDisplayMode(_this, desktopmoderef, link, &desktopmode)) {
|
||||
if (!SDL_AddDisplayMode(display, &desktopmode)) {
|
||||
CGDisplayModeRelease(desktopmoderef);
|
||||
SDL_free(desktopmode.driverdata);
|
||||
}
|
||||
} else {
|
||||
CGDisplayModeRelease(desktopmoderef);
|
||||
}
|
||||
|
||||
modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
|
||||
|
||||
if (modes) {
|
||||
CFIndex i;
|
||||
const CFIndex count = CFArrayGetCount(modes);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
CGDisplayModeRef moderef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
if (GetDisplayMode(_this, moderef, link, &mode)) {
|
||||
if (SDL_AddDisplayMode(display, &mode)) {
|
||||
CGDisplayModeRetain(moderef);
|
||||
if (!SDL_AddDisplayMode(display, &mode)) {
|
||||
} else {
|
||||
SDL_free(mode.driverdata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CVDisplayLinkRelease(link);
|
||||
CFRelease(modes);
|
||||
}
|
||||
|
||||
CVDisplayLinkRelease(link);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in a new issue