Allow changing the fullscreen resolution on OS X.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7011 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang
2011-01-31 07:38:36 +00:00
parent 0e91e5b238
commit e0e4a3ae02
4 changed files with 61 additions and 41 deletions

View File

@ -37,6 +37,10 @@ Core::GetWindowHandle().
#include "Timer.h"
#include "VideoBackendBase.h"
#ifdef __APPLE__
#include <ApplicationServices/ApplicationServices.h>
#endif
#include "Globals.h" // Local
#include "Frame.h"
#include "ConfigMain.h"
@ -768,6 +772,34 @@ void CFrame::ToggleDisplayMode(bool bFullscreen)
}
#elif defined(HAVE_XRANDR) && HAVE_XRANDR
m_XRRConfig->ToggleDisplayMode(bFullscreen);
#elif defined __APPLE__
CFArrayRef modes = CGDisplayAvailableModes(CGMainDisplayID());
for (CFIndex i = 0; i < CFArrayGetCount(modes); i++)
{
CFDictionaryRef mode;
CFNumberRef ref;
int x, y, w, h, d;
sscanf(SConfig::GetInstance().m_LocalCoreStartupParameter.\
strFullscreenResolution.c_str(), "%dx%d", &x, &y);
mode = (CFDictionaryRef)CFArrayGetValueAtIndex(modes, i);
ref = (CFNumberRef)CFDictionaryGetValue(mode, kCGDisplayWidth);
CFNumberGetValue(ref, kCFNumberIntType, &w);
ref = (CFNumberRef)CFDictionaryGetValue(mode, kCGDisplayHeight);
CFNumberGetValue(ref, kCFNumberIntType, &h);
ref = (CFNumberRef)CFDictionaryGetValue(mode,
kCGDisplayBitsPerPixel);
CFNumberGetValue(ref, kCFNumberIntType, &d);
if (w != x || h != y || d != 32)
continue;;
if (bFullscreen)
CGDisplaySwitchToMode(CGMainDisplayID(), mode);
else
CGRestorePermanentDisplayConfiguration();
}
#endif
}