From 0a4f26c296dd6bc7a2e245e3fc24610ba77b7430 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 3 Sep 2023 23:12:53 +1000 Subject: [PATCH] Mac: Make cocoa backend compile on macOS 10.3 --- src/interop_cocoa.m | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/interop_cocoa.m b/src/interop_cocoa.m index 94634648c..52a892b03 100644 --- a/src/interop_cocoa.m +++ b/src/interop_cocoa.m @@ -244,12 +244,12 @@ static void RefreshWindowBounds(void) { @end -static void DoDrawFramebuffer(CGRect dirty); +static void DoDrawFramebuffer(NSRect dirty); @interface CCView : NSView { } @end @implementation CCView -- (void)drawRect:(CGRect)dirty { DoDrawFramebuffer(dirty); } +- (void)drawRect:(NSRect)dirty { DoDrawFramebuffer(dirty); } - (void)viewDidEndLiveResize { // When the user users left mouse to drag reisze window, this enters 'live resize' mode @@ -443,6 +443,7 @@ static int TryGetKey(NSEvent* ev) { } static void DebugScrollEvent(NSEvent* ev) { +#ifdef kCGScrollWheelEventDeltaAxis1 float dy = [ev deltaY]; int steps = dy > 0.0f ? Math_Ceil(dy) : Math_Floor(dy); @@ -451,12 +452,13 @@ static void DebugScrollEvent(NSEvent* ev) { int raw = CGEventGetIntegerValueField(ref, kCGScrollWheelEventDeltaAxis1); Platform_Log3("SCROLL: %i.0 = (%i, %f3)", &steps, &raw, &dy); +#endif } void Window_ProcessEvents(double delta) { NSEvent* ev; int key, type, steps, x, y; - CGFloat dx, dy; + float dx, dy; // https://wiki.freepascal.org/Cocoa_Internals/Application [pool release]; @@ -560,7 +562,9 @@ void ShowDialogCore(const char* title, const char* msg) { static NSMutableArray* GetOpenSaveFilters(const char* const* filters) { NSMutableArray* types = [NSMutableArray array]; - for (int i = 0; filters[i]; i++) + int i; + + for (i = 0; filters[i]; i++) { NSString* filter = [NSString stringWithUTF8String:filters[i]]; filter = [filter substringFromIndex:1]; @@ -630,7 +634,7 @@ void Window_AllocFramebuffer(struct Bitmap* bmp) { fb_bmp = *bmp; } -static void DoDrawFramebuffer(CGRect dirty) { +static void DoDrawFramebuffer(NSRect dirty) { CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = NULL; CGDataProviderRef provider;