Ver Fonte

More changes to fix building with older macOS SDKs

Sam Lantinga há 2 anos atrás
pai
commit
f4c1260120
2 ficheiros alterados com 10 adições e 8 exclusões
  1. 2 3
      src/video/cocoa/SDL_cocoaevents.m
  2. 8 5
      src/video/cocoa/SDL_cocoavideo.m

+ 2 - 3
src/video/cocoa/SDL_cocoaevents.m

@@ -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());

+ 8 - 5
src/video/cocoa/SDL_cocoavideo.m

@@ -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 */