Add conditionals to maintain backwards compatibility with OSX 10.5

This commit is contained in:
twinaphex 2018-08-30 16:22:02 +02:00
parent d7899c51aa
commit 1222192afb

View File

@ -42,6 +42,7 @@
#import <MetalKit/MetalKit.h> #import <MetalKit/MetalKit.h>
#endif #endif
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
@interface WindowListener : NSResponder<NSWindowDelegate> @interface WindowListener : NSResponder<NSWindowDelegate>
@end @end
@ -59,6 +60,7 @@
{} {}
@end @end
#endif
id<ApplePlatform> apple_platform; id<ApplePlatform> apple_platform;
@ -72,7 +74,9 @@ 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
WindowListener *_listener; WindowListener *_listener;
#endif
} }
@property (nonatomic, retain) NSWindow IBOutlet* window; @property (nonatomic, retain) NSWindow IBOutlet* window;
@ -264,11 +268,15 @@ static char** waiting_argv;
} }
#endif #endif
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
_listener = [WindowListener new]; _listener = [WindowListener new];
#endif
[self.window setAcceptsMouseMovedEvents: YES]; [self.window setAcceptsMouseMovedEvents: YES];
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
[self.window setNextResponder:_listener]; [self.window setNextResponder:_listener];
self.window.delegate = _listener; self.window.delegate = _listener;
#endif
[[self.window contentView] setAutoresizesSubviews:YES]; [[self.window contentView] setAutoresizesSubviews:YES];
@ -286,8 +294,10 @@ static char** waiting_argv;
waiting_argc = 0; waiting_argc = 0;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
[self.window makeMainWindow]; [self.window makeMainWindow];
[self.window makeKeyWindow]; [self.window makeKeyWindow];
#endif
[self performSelectorOnMainThread:@selector(rarch_main) withObject:nil waitUntilDone:NO]; [self performSelectorOnMainThread:@selector(rarch_main) withObject:nil waitUntilDone:NO];
} }
@ -305,7 +315,9 @@ 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
self.window.contentView = nil; self.window.contentView = nil;
#endif
_renderView = nil; _renderView = nil;
} }
@ -336,8 +348,13 @@ 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
self.window.contentView = _renderView; self.window.contentView = _renderView;
[self.window.contentView setNextResponder:_listener]; [self.window.contentView setNextResponder:_listener];
#else
[self.window.contentView addSubview:_renderView];
[self.window makeFirstResponder:_renderView];
#endif
} }
- (apple_view_type_t)viewType { - (apple_view_type_t)viewType {