--- a/src/video/cocoa/cocoa_v.mm Fri Nov 23 16:59:30 2007 +0000
+++ b/src/video/cocoa/cocoa_v.mm Wed Jan 09 18:11:12 2008 +0000
@@ -8,6 +8,7 @@
#ifdef WITH_COCOA
+#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_3
#include <AvailabilityMacros.h>
#import <Cocoa/Cocoa.h>
@@ -55,17 +56,12 @@
#include "../../stdafx.h"
#include "../../openttd.h"
#include "../../debug.h"
-#include "../../macros.h"
-#include "../../os/macosx/splash.h"
#include "../../variables.h"
-#include "../../gfx.h"
+#include "../../core/geometry_type.hpp"
#include "cocoa_v.h"
-#include "cocoa_keys.h"
#include "../../blitter/factory.hpp"
#include "../../fileio.h"
-
-#undef Point
-#undef Rect
+#include "../../gfx_func.h"
@interface OTTDMain : NSObject
@@ -202,7 +198,7 @@
static void QZ_UpdateVideoModes()
{
uint i, count;
- OTTDPoint modes[32];
+ OTTD_Point modes[32];
assert(_cocoa_subdriver != NULL);
@@ -233,13 +229,37 @@
static CocoaSubdriver *QZ_CreateWindowSubdriver(int width, int height, int bpp)
{
- long sysVersion;
+ CocoaSubdriver *ret;
- if (Gestalt(gestaltSystemVersion, &sysVersion) == noErr && sysVersion >= 0x1040) {
- return QZ_CreateWindowQuartzSubdriver(width, height, bpp);
+#ifdef ENABLE_COCOA_QUARTZ
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+ /* The reason for the version mismatch is due to the fact that the 10.4 binary needs to work on 10.5 as well. */
+ if (MacOSVersionIsAtLeast(10, 5, 0)) {
+ ret = QZ_CreateWindowQuartzSubdriver(width, height, bpp);
+ if (ret != NULL) return ret;
}
+#endif
+#endif
- return QZ_CreateWindowQuickdrawSubdriver(width, height, bpp);
+#ifdef ENABLE_COCOA_QUICKDRAW
+ ret = QZ_CreateWindowQuickdrawSubdriver(width, height, bpp);
+ if (ret != NULL) return ret;
+#endif
+
+#ifdef ENABLE_COCOA_QUARTZ
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+ /*
+ * If we get here we are running 10.4 or earlier and either openttd was compiled without the quickdraw driver
+ * or it failed to load for some reason. Fall back to Quartz if possible even though that driver is slower.
+ */
+ if (MacOSVersionIsAtLeast(10, 4, 0)) {
+ ret = QZ_CreateWindowQuartzSubdriver(width, height, bpp);
+ if (ret != NULL) return ret;
+ }
+#endif
+#endif
+
+ return NULL;
}
@@ -286,6 +306,8 @@
{
int width, height, bpp;
+ if (!MacOSVersionIsAtLeast(10, 3, 0)) return "The Cocoa video driver requires Mac OS X 10.3 or later.";
+
if (_cocoa_video_started) return "Already started";
_cocoa_video_started = true;
@@ -339,7 +361,7 @@
return ret;
}
-void VideoDriver_Cocoa::ToggleFullscreen(bool full_screen)
+bool VideoDriver_Cocoa::ToggleFullscreen(bool full_screen)
{
bool oldfs;
@@ -364,6 +386,7 @@
QZ_GameSizeChanged();
QZ_UpdateVideoModes();
+ return _cocoa_subdriver->IsFullscreen() == full_screen;
}