From 64d6df38670e303fcf745ebc6b1af0893df4ba4f Mon Sep 17 00:00:00 2001 From: Joshua Root Date: Fri, 3 Jan 2025 03:40:34 +1100 Subject: [PATCH 1/3] showAlert: legacy OS compatibility fix --- src/video/cocoa/SDL_cocoamessagebox.m | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/video/cocoa/SDL_cocoamessagebox.m b/src/video/cocoa/SDL_cocoamessagebox.m index 90b0644a967e7..20eabe3eeece5 100644 --- a/src/video/cocoa/SDL_cocoamessagebox.m +++ b/src/video/cocoa/SDL_cocoamessagebox.m @@ -33,6 +33,9 @@ @interface SDLMessageBoxPresenter : NSObject { NSWindow *nswindow; } - (id)initWithParentWindow:(SDL_Window *)window; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 +- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo; +#endif @end @implementation SDLMessageBoxPresenter @@ -56,16 +59,32 @@ - (id) initWithParentWindow:(SDL_Window *)window - (void)showAlert:(NSAlert*)alert { if (nswindow) { - [alert beginSheetModalForWindow:nswindow +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 + if ([alert respondsToSelector:@selector(beginSheetModalForWindow:completionHandler:)]) { + [alert beginSheetModalForWindow:nswindow completionHandler:^(NSModalResponse returnCode) { [NSApp stopModalWithCode:returnCode]; }]; + } else +#endif + { +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 + [alert beginSheetModalForWindow:nswindow modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil]; +#endif + } clicked = [NSApp runModalForWindow:nswindow]; nswindow = nil; } else { clicked = [alert runModal]; } } + +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 +- (void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo +{ + [NSApp stopModalWithCode:returnCode]; +} +#endif @end From 158c0887c890ad7d8b9c1df0fbc98f7b25e12565 Mon Sep 17 00:00:00 2001 From: Joshua Root Date: Fri, 3 Jan 2025 04:19:51 +1100 Subject: [PATCH 2/3] windowWillStartLiveResize: legacy OS compatibility fix --- src/video/cocoa/SDL_cocoawindow.h | 1 + src/video/cocoa/SDL_cocoawindow.m | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h index 2f9324617aafe..7ef0bc036414e 100644 --- a/src/video/cocoa/SDL_cocoawindow.h +++ b/src/video/cocoa/SDL_cocoawindow.h @@ -78,6 +78,7 @@ typedef enum /* Window delegate functionality */ -(BOOL) windowShouldClose:(id) sender; -(void) windowDidExpose:(NSNotification *) aNotification; +-(void) onLiveResizeTimerFire:(id) sender; -(void) windowWillStartLiveResize:(NSNotification *)aNotification; -(void) windowDidEndLiveResize:(NSNotification *)aNotification; -(void) windowDidMove:(NSNotification *) aNotification; diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 0dc638390ae5d..19e5aae306e91 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -743,16 +743,26 @@ - (void)windowDidExpose:(NSNotification *)aNotification SDL_SendWindowEvent(_data.window, SDL_WINDOWEVENT_EXPOSED, 0, 0); } +- (void)onLiveResizeTimerFire:(id)sender +{ + SDL_OnWindowLiveResizeUpdate(_data.window); +} + - (void)windowWillStartLiveResize:(NSNotification *)aNotification { // We'll try to maintain 60 FPS during live resizing const NSTimeInterval interval = 1.0 / 60.0; + + NSMethodSignature *invocationSig = [Cocoa_WindowListener + instanceMethodSignatureForSelector:@selector(onLiveResizeTimerFire:)]; + NSInvocation *invocation = [NSInvocation + invocationWithMethodSignature:invocationSig]; + [invocation setTarget:self]; + [invocation setSelector:@selector(onLiveResizeTimerFire:)]; + liveResizeTimer = [NSTimer scheduledTimerWithTimeInterval:interval - repeats:TRUE - block:^(NSTimer *unusedTimer) - { - SDL_OnWindowLiveResizeUpdate(_data.window); - }]; + invocation:invocation + repeats:TRUE]; [[NSRunLoop currentRunLoop] addTimer:liveResizeTimer forMode:NSRunLoopCommonModes]; } From 1219934e7cfbe6d3841cc85912e1bec9f17b93ab Mon Sep 17 00:00:00 2001 From: Joshua Root Date: Fri, 3 Jan 2025 07:35:17 +1100 Subject: [PATCH 3/3] prepare_audioqueue: legacy OS compatibility fix --- src/audio/coreaudio/SDL_coreaudio.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m index cbf213b4257ff..9eb580bb1d0bb 100644 --- a/src/audio/coreaudio/SDL_coreaudio.m +++ b/src/audio/coreaudio/SDL_coreaudio.m @@ -880,14 +880,25 @@ static int prepare_audioqueue(_THIS) // L R C LFE Ls Rs layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_12; break; +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000) || \ + (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101500) case 7: // L R C LFE Cs Ls Rs - layout.mChannelLayoutTag = kAudioChannelLayoutTag_WAVE_6_1; + if (@available(macOS 10.15, iOS 13, *)) { + layout.mChannelLayoutTag = kAudioChannelLayoutTag_WAVE_6_1; + } else { + return SDL_SetError("Unsupported audio channels"); + } break; case 8: // L R C LFE Rls Rrs Ls Rs - layout.mChannelLayoutTag = kAudioChannelLayoutTag_WAVE_7_1; + if (@available(macOS 10.15, iOS 13, *)) { + layout.mChannelLayoutTag = kAudioChannelLayoutTag_WAVE_7_1; + } else { + return SDL_SetError("Unsupported audio channels"); + } break; +#endif default: return SDL_SetError("Unsupported audio channels"); }