Use constant values instead of MAC_OS_X_VERSION_ - might not be available on earlier OSX versions/xcode

This commit is contained in:
neville 2018-08-30 16:29:58 +02:00
parent 1222192afb
commit f35b578c42
2 changed files with 13 additions and 9 deletions

View File

@ -80,7 +80,7 @@ static enum ui_msg_window_response ui_msg_window_cocoa_dialog(ui_msg_window_stat
break; break;
} }
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
[alert beginSheetModalForWindow:(BRIDGE NSWindow *)ui_companion_driver_get_main_window() [alert beginSheetModalForWindow:(BRIDGE NSWindow *)ui_companion_driver_get_main_window()
completionHandler:^(NSModalResponse returnCode) { completionHandler:^(NSModalResponse returnCode) {
[[NSApplication sharedApplication] stopModalWithCode:returnCode]; [[NSApplication sharedApplication] stopModalWithCode:returnCode];

View File

@ -42,6 +42,10 @@
#import <MetalKit/MetalKit.h> #import <MetalKit/MetalKit.h>
#endif #endif
#ifndef MAC_OS_X_VERSION_10_6
#define MAC_OS_X_VERSION_10_6 1060
#endif
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
@interface WindowListener : NSResponder<NSWindowDelegate> @interface WindowListener : NSResponder<NSWindowDelegate>
@end @end
@ -74,7 +78,7 @@ id<ApplePlatform> apple_platform;
apple_view_type_t _vt; apple_view_type_t _vt;
NSView* _renderView; NSView* _renderView;
id _sleepActivity; id _sleepActivity;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
WindowListener *_listener; WindowListener *_listener;
#endif #endif
} }
@ -255,7 +259,7 @@ static char** waiting_argv;
{ {
unsigned i; unsigned i;
apple_platform = self; apple_platform = self;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
self.window.collectionBehavior = NSWindowCollectionBehaviorFullScreenPrimary; self.window.collectionBehavior = NSWindowCollectionBehaviorFullScreenPrimary;
#else #else
SEL selector = NSSelectorFromString(BOXSTRING("setCollectionBehavior:")); SEL selector = NSSelectorFromString(BOXSTRING("setCollectionBehavior:"));
@ -268,12 +272,12 @@ static char** waiting_argv;
} }
#endif #endif
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
_listener = [WindowListener new]; _listener = [WindowListener new];
#endif #endif
[self.window setAcceptsMouseMovedEvents: YES]; [self.window setAcceptsMouseMovedEvents: YES];
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
[self.window setNextResponder:_listener]; [self.window setNextResponder:_listener];
self.window.delegate = _listener; self.window.delegate = _listener;
#endif #endif
@ -294,7 +298,7 @@ static char** waiting_argv;
waiting_argc = 0; waiting_argc = 0;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
[self.window makeMainWindow]; [self.window makeMainWindow];
[self.window makeKeyWindow]; [self.window makeKeyWindow];
#endif #endif
@ -315,7 +319,7 @@ static char** waiting_argv;
_renderView.wantsLayer = NO; _renderView.wantsLayer = NO;
_renderView.layer = nil; _renderView.layer = nil;
[_renderView removeFromSuperview]; [_renderView removeFromSuperview];
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
self.window.contentView = nil; self.window.contentView = nil;
#endif #endif
_renderView = nil; _renderView = nil;
@ -348,7 +352,7 @@ static char** waiting_argv;
_renderView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; _renderView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
_renderView.frame = self.window.contentView.bounds; _renderView.frame = self.window.contentView.bounds;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
self.window.contentView = _renderView; self.window.contentView = _renderView;
[self.window.contentView setNextResponder:_listener]; [self.window.contentView setNextResponder:_listener];
#else #else
@ -399,7 +403,7 @@ static char** waiting_argv;
- (bool)setDisableDisplaySleep:(bool)disable - (bool)setDisableDisplaySleep:(bool)disable
{ {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
if (disable && _sleepActivity == nil) if (disable && _sleepActivity == nil)
{ {
_sleepActivity = [NSProcessInfo.processInfo beginActivityWithOptions:NSActivityIdleDisplaySleepDisabled reason:@"disable screen saver"]; _sleepActivity = [NSProcessInfo.processInfo beginActivityWithOptions:NSActivityIdleDisplaySleepDisabled reason:@"disable screen saver"];