Allow compilation with SDK 10.10 and use new API to discover os version at runtime.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10305 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2014-09-13 14:29:53 +00:00
parent 6482acf15a
commit 76418b352b
2 changed files with 10 additions and 1 deletions

View File

@ -64,6 +64,12 @@ typedef CGContextRef Fl_Offscreen;
#ifndef MAC_OS_X_VERSION_10_8 #ifndef MAC_OS_X_VERSION_10_8
#define MAC_OS_X_VERSION_10_8 1080 #define MAC_OS_X_VERSION_10_8 1080
#endif #endif
#ifndef MAC_OS_X_VERSION_10_9
#define MAC_OS_X_VERSION_10_9 1090
#endif
#ifndef MAC_OS_X_VERSION_10_10
#define MAC_OS_X_VERSION_10_10 101000
#endif
#ifdef __OBJC__ #ifdef __OBJC__
@class NSCursor; @class NSCursor;

View File

@ -3870,13 +3870,16 @@ void *Fl_X::get_carbon_function(const char *function_name) {
static int calc_mac_os_version() { static int calc_mac_os_version() {
int M, m, b = 0; int M, m, b = 0;
NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) { if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) {
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion]; NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
M = version.majorVersion; M = version.majorVersion;
m = version.minorVersion; m = version.minorVersion;
b = version.patchVersion; b = version.patchVersion;
} }
else { else
#endif
{
NSDictionary * sv = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"]; NSDictionary * sv = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
const char *s = [[sv objectForKey:@"ProductVersion"] UTF8String]; const char *s = [[sv objectForKey:@"ProductVersion"] UTF8String];
sscanf(s, "%d.%d.%d", &M, &m, &b); sscanf(s, "%d.%d.%d", &M, &m, &b);