From e0e4a3ae02e2419f4ea2a92393c9cc446515e5f6 Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Mon, 31 Jan 2011 07:38:36 +0000 Subject: [PATCH] Allow changing the fullscreen resolution on OS X. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7011 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/SConscript | 1 + Source/Core/DolphinWX/Src/ConfigMain.cpp | 56 ++++++++++-------------- Source/Core/DolphinWX/Src/FrameTools.cpp | 32 ++++++++++++++ Source/Core/DolphinWX/Src/SConscript | 13 +++--- 4 files changed, 61 insertions(+), 41 deletions(-) diff --git a/Source/Core/Common/Src/SConscript b/Source/Core/Common/Src/SConscript index 719e4d9241..eb076681fa 100644 --- a/Source/Core/Common/Src/SConscript +++ b/Source/Core/Common/Src/SConscript @@ -8,6 +8,7 @@ def createVersion(env, target, source): from SconsTests import utils utils.GenerateRevFile(env['flavor'], source[0].path, target[0].path) +Execute(Delete('svnrev.h')) env.Command('svnrev.h', 'svnrev_template.h', [Delete('${TARGET.srcpath}'), createVersion]) diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index aa163a8e4a..431dbfa093 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -1377,43 +1377,33 @@ void CConfigMain::AddResolutions() #elif defined(HAVE_XRANDR) && HAVE_XRANDR main_frame->m_XRRConfig->AddResolutions(arrayStringFor_FullscreenResolution); #elif defined(__APPLE__) - CFDictionaryRef mode; - CFArrayRef array; - CFIndex n, i; - int w, h; - std::vector resos; - - array = CGDisplayAvailableModes(CGMainDisplayID()); - n = CFArrayGetCount(array); - - for (i = 0; i < n; i++) + CFArrayRef modes = CGDisplayAvailableModes(CGMainDisplayID()); + for (CFIndex i = 0; i < CFArrayGetCount(modes); i++) { - mode = (CFDictionaryRef)CFArrayGetValueAtIndex(array, i); - - CFNumberRef anWidth = (CFNumberRef)CFDictionaryGetValue(mode, - kCGDisplayWidth); - if (NULL == anWidth || - !CFNumberGetValue(anWidth, kCFNumberIntType, &w)) + std::stringstream res; + CFDictionaryRef mode; + CFNumberRef ref; + int w, h, d; + + 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 (CFDictionaryContainsKey(mode, kCGDisplayModeIsInterlaced)) + continue; + if (CFDictionaryContainsKey(mode, kCGDisplayModeIsStretched)) + continue; + if (d != 32) continue; - CFNumberRef anHeight = - (CFNumberRef)CFDictionaryGetValue(mode, - kCGDisplayHeight); - if (NULL == anHeight || - !CFNumberGetValue(anHeight, kCFNumberIntType, &h)) - continue; - - char res[32]; - sprintf(res,"%dx%d", w, h); - std::string strRes(res); + res << w << "x" << h; - // Only add unique resolutions - if (std::find(resos.begin(), resos.end(), strRes) == - resos.end()) - { - resos.push_back(strRes); - arrayStringFor_FullscreenResolution.Add(strRes); - } + arrayStringFor_FullscreenResolution.Add(res.str()); } #endif } diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 19bcda3c17..8b373145a8 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -37,6 +37,10 @@ Core::GetWindowHandle(). #include "Timer.h" #include "VideoBackendBase.h" +#ifdef __APPLE__ +#include +#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 } diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript index 23ce1fcc4d..8e7f78ad08 100644 --- a/Source/Core/DolphinWX/Src/SConscript +++ b/Source/Core/DolphinWX/Src/SConscript @@ -6,10 +6,8 @@ import sys from SconsTests import utils files = ['BootManager.cpp'] - -ldflags = [ ] - -libs = [ ] +ldflags = [] +libs = [] if not env['HAVE_WX']: files += ['MainNoGUI.cpp'] @@ -51,11 +49,11 @@ else: libs += ['debwx', 'debugger_ui_util', 'dolphinwx'] -libs += ['core', 'discio', 'plugin_videoogl'] # 'plugin_videosoftware' +libs += ['core', 'common', 'discio', 'plugin_videoogl'] # 'plugin_videosoftware' if env['HAVE_WX']: libs += ['videouicommon'] -libs += ['audiocommon', 'common', 'inputcommon', 'videocommon'] -libs += ['GLEW', 'SOIL', 'bdisasm', 'lua', 'lzo2', 'sfml-network', 'z'] +libs += ['audiocommon', 'inputcommon', 'videocommon'] +libs += ['GLEW', 'SOIL', 'bdisasm', 'lua', 'lzo2', 'sfml-network', 'z'] if sys.platform == 'win32': files += [ "stdafx.cpp" ] @@ -71,7 +69,6 @@ elif sys.platform == 'darwin': libs += [ 'iconv' ] exe += 'NoGUI' - env.Install('#' + env['prefix'] + '/Dolphin.app/Contents/' + 'Frameworks/Cg.framework', source = [ '#Externals/Cg/Cg.framework/Cg',