summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorplanetmaker <planetmaker@openttd.org>2011-09-05 15:52:04 +0000
committerplanetmaker <planetmaker@openttd.org>2011-09-05 15:52:04 +0000
commit20e359acbef3ec3a7cefd8c635a7032af090117d (patch)
treeebaff1008a7af6c52b2e362c7ca0b008f2c4d904
parent45b099c655d9c205370f5a5f15107863979b2592 (diff)
downloadopenttd-20e359acbef3ec3a7cefd8c635a7032af090117d.tar.xz
(svn r22895) -Add: [OSX] Alternative code for the API calls deprecated in OSX 10.6 in the quartz video driver
-rw-r--r--src/video/cocoa/wnd_quartz.mm18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/video/cocoa/wnd_quartz.mm b/src/video/cocoa/wnd_quartz.mm
index 356b7ac7e..0559b5c40 100644
--- a/src/video/cocoa/wnd_quartz.mm
+++ b/src/video/cocoa/wnd_quartz.mm
@@ -206,10 +206,14 @@ static CGColorSpaceRef QZ_GetCorrectColorSpace()
void WindowQuartzSubdriver::GetDeviceInfo()
{
- /* Initialize the video settings; this data persists between mode switches */
+ /* Initialize the video settings; this data persists between mode switches
+ * and gather some information that is useful to know about the display */
+
+# if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
+ /* This way is deprecated as of OSX 10.6 but continues to work.Thus use it
+ * always, unless allowed to skip compatibility with 10.5 and earlier */
CFDictionaryRef cur_mode = CGDisplayCurrentMode(kCGDirectMainDisplay);
- /* Gather some information that is useful to know about the display */
CFNumberGetValue(
(const __CFNumber*)CFDictionaryGetValue(cur_mode, kCGDisplayWidth),
kCFNumberSInt32Type, &this->device_width
@@ -219,6 +223,16 @@ void WindowQuartzSubdriver::GetDeviceInfo()
(const __CFNumber*)CFDictionaryGetValue(cur_mode, kCGDisplayHeight),
kCFNumberSInt32Type, &this->device_height
);
+# else
+ /* Use the new API when compiling for OSX 10.6 or later */
+ CGDisplayModeRef cur_mode = CGDisplayCopyDisplayMode(kCGDirectMainDisplay);
+ if (cur_mode == NULL) { return; }
+
+ this->device_width = CGDisplayModeGetWidth(cur_mode);
+ this->device_height = CGDisplayModeGetHeight(cur_mode);
+
+ CGDisplayModeRelease(cur_mode);
+# endif
}
/** Switch to full screen mode on OSX 10.7