From 0c3db932b22e3ba9e033ce4391c9d8dd5b99f0d6 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 11 Apr 2020 18:19:15 +0300 Subject: [PATCH] Fix Mavericks compatibility --- Cocoa/Document.m | 14 ++++++-------- Cocoa/GBSplitView.h | 2 +- Cocoa/GBSplitView.m | 10 ++++++++++ Cocoa/GBViewMetal.m | 2 ++ Cocoa/NSObject+MavericksCompat.m | 7 +++++++ Makefile | 2 +- 6 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 Cocoa/NSObject+MavericksCompat.m diff --git a/Cocoa/Document.m b/Cocoa/Document.m index 71436d3..0114658 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -817,9 +817,7 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample) } if (![console_output_timer isValid]) { - console_output_timer = [NSTimer timerWithTimeInterval:(NSTimeInterval)0.05 repeats:NO block:^(NSTimer * _Nonnull timer) { - [self appendPendingOutput]; - }]; + console_output_timer = [NSTimer timerWithTimeInterval:(NSTimeInterval)0.05 target:self selector:@selector(appendPendingOutput) userInfo:nil repeats:NO]; [[NSRunLoop mainRunLoop] addTimer:console_output_timer forMode:NSDefaultRunLoopMode]; } @@ -1665,7 +1663,7 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample) } -- (BOOL)splitView:(NSSplitView *)splitView canCollapseSubview:(NSView *)subview; +- (BOOL)splitView:(GBSplitView *)splitView canCollapseSubview:(NSView *)subview; { if ([[splitView arrangedSubviews] lastObject] == subview) { return YES; @@ -1673,16 +1671,16 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample) return NO; } -- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex +- (CGFloat)splitView:(GBSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex { return 600; } -- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMaximumPosition ofSubviewAt:(NSInteger)dividerIndex { +- (CGFloat)splitView:(GBSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMaximumPosition ofSubviewAt:(NSInteger)dividerIndex { return splitView.frame.size.width - 321; } -- (BOOL)splitView:(NSSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)view { +- (BOOL)splitView:(GBSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)view { if ([[splitView arrangedSubviews] lastObject] == view) { return NO; } @@ -1691,7 +1689,7 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample) - (void)splitViewDidResizeSubviews:(NSNotification *)notification { - NSSplitView *splitview = notification.object; + GBSplitView *splitview = notification.object; if ([[[splitview arrangedSubviews] firstObject] frame].size.width < 600) { [splitview setPosition:600 ofDividerAtIndex:0]; } diff --git a/Cocoa/GBSplitView.h b/Cocoa/GBSplitView.h index 7b2faa2..6ab97cf 100644 --- a/Cocoa/GBSplitView.h +++ b/Cocoa/GBSplitView.h @@ -3,5 +3,5 @@ @interface GBSplitView : NSSplitView -(void) setDividerColor:(NSColor *)color; - +- (NSArray *)arrangedSubviews; @end diff --git a/Cocoa/GBSplitView.m b/Cocoa/GBSplitView.m index 0a30fe0..0fb3bc4 100644 --- a/Cocoa/GBSplitView.m +++ b/Cocoa/GBSplitView.m @@ -17,4 +17,14 @@ return [super dividerColor]; } +/* Mavericks comaptibility */ +- (NSArray *)arrangedSubviews +{ + if (@available(macOS 10.11, *)) { + return [super arrangedSubviews]; + } else { + return [self subviews]; + } +} + @end diff --git a/Cocoa/GBViewMetal.m b/Cocoa/GBViewMetal.m index 4c8a5d5..62deadc 100644 --- a/Cocoa/GBViewMetal.m +++ b/Cocoa/GBViewMetal.m @@ -1,4 +1,6 @@ #import "GBViewMetal.h" +#pragma clang diagnostic ignored "-Wpartial-availability" + static const vector_float2 rect[] = { diff --git a/Cocoa/NSObject+MavericksCompat.m b/Cocoa/NSObject+MavericksCompat.m new file mode 100644 index 0000000..6c06514 --- /dev/null +++ b/Cocoa/NSObject+MavericksCompat.m @@ -0,0 +1,7 @@ +#import +@implementation NSObject (MavericksCompat) +- (instancetype)initWithCoder:(NSCoder *)coder +{ + return [self init]; +} +@end diff --git a/Makefile b/Makefile index 5923b2e..36a893d 100644 --- a/Makefile +++ b/Makefile @@ -88,7 +88,7 @@ OPEN_DIALOG = OpenDialog/cocoa.m endif -CFLAGS += -Werror -Wall -Wno-nonnull -Wno-unused-result -Wno-strict-aliasing -Wno-unknown-warning -Wno-unknown-warning-option -Wno-multichar -Wno-int-in-bool-context -std=gnu11 -D_GNU_SOURCE -DVERSION="$(VERSION)" -I. -D_USE_MATH_DEFINES +CFLAGS += -Werror -Wall -Wpartial-availability -Wno-nonnull -Wno-unused-result -Wno-strict-aliasing -Wno-unknown-warning -Wno-unknown-warning-option -Wno-multichar -Wno-int-in-bool-context -std=gnu11 -D_GNU_SOURCE -DVERSION="$(VERSION)" -I. -D_USE_MATH_DEFINES ifeq (,$(PKG_CONFIG)) SDL_CFLAGS := $(shell sdl2-config --cflags) SDL_LDFLAGS := $(shell sdl2-config --libs)