More changes to fix building with older macOS SDKs

main
Sam Lantinga 2023-03-10 16:38:45 -08:00
parent c044cff4c7
commit f4c1260120
2 changed files with 10 additions and 8 deletions

View File

@ -27,7 +27,6 @@
#ifndef MAC_OS_X_VERSION_10_12
#define NSEventTypeApplicationDefined NSApplicationDefined
typedef NSString *NSKeyValueChangeKey;
#endif
static SDL_Window *FindSDLWindowForNSWindow(NSWindow *win)
@ -132,7 +131,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
- (void)localeDidChange:(NSNotification *)notification;
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary<NSKeyValueChangeKey, id> *)change
change:(NSDictionary *)change
context:(void *)context;
@end
@ -280,7 +279,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary<NSKeyValueChangeKey, id> *)change
change:(NSDictionary *)change
context:(void *)context
{
SDL_SetSystemTheme(Cocoa_GetSystemTheme());

View File

@ -226,13 +226,16 @@ void Cocoa_VideoQuit(_THIS)
/* This function assumes that it's called from within an autorelease pool */
SDL_SystemTheme Cocoa_GetSystemTheme(void)
{
NSAppearance* appearance = [[NSApplication sharedApplication] effectiveAppearance];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 /* Added in the 10.14.0 SDK. */
if ([[NSApplication sharedApplication] respondsToSelector:@selector(effectiveAppearance)]) {
NSAppearance* appearance = [[NSApplication sharedApplication] effectiveAppearance];
if ([appearance.name containsString: @"Dark"]) {
return SDL_SYSTEM_THEME_DARK;
} else {
return SDL_SYSTEM_THEME_LIGHT;
if ([appearance.name containsString: @"Dark"]) {
return SDL_SYSTEM_THEME_DARK;
}
}
#endif
return SDL_SYSTEM_THEME_LIGHT;
}
/* This function assumes that it's called from within an autorelease pool */