Commit 4b112620a3778f2a5437d73e6d7bf1d2b76002ae

Ozkan Sezer 2022-01-02T19:11:50

SDL_cocoamodes.m (Cocoa_GetDisplayDPI): fix build using older toolchains Fixes https://github.com/libsdl-org/SDL/issues/5162

diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m
index 5ed1f41..2ec446b 100644
--- a/src/video/cocoa/SDL_cocoamodes.m
+++ b/src/video/cocoa/SDL_cocoamodes.m
@@ -461,9 +461,9 @@ Cocoa_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdp
     for (NSScreen *screen in screens) {
         const CGDirectDisplayID dpyid = (const CGDirectDisplayID ) [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue];
         if (dpyid == data->display) {
-        
+#ifdef MAC_OS_X_VERSION_10_8
             /* Neither CGDisplayScreenSize(description's NSScreenNumber) nor [NSScreen backingScaleFactor] can calculate the correct dpi in macOS. E.g. backingScaleFactor is always 2 in all display modes for rMBP 16" */
-            if (@available(macOS 10.8, *)) {
+            if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) {
                 CFStringRef dmKeys[1] = { kCGDisplayShowDuplicateLowResolutionModes };
                 CFBooleanRef dmValues[1] = { kCFBooleanTrue };
                 CFDictionaryRef dmOptions = CFDictionaryCreate(kCFAllocatorDefault, (const void**) dmKeys, (const void**) dmValues, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks );
@@ -492,14 +492,15 @@ Cocoa_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdp
                 }
                 CFRelease(allDisplayModes);
                 CFRelease(dmOptions);
-            } else if (@available(macOS 10.7, *)) {
+            } else
+#endif
+            if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
                 // fallback for 10.7
                 scaleFactor = [screen backingScaleFactor];
                 displayNativeSize.width = displayNativeSize.width * scaleFactor;
                 displayNativeSize.height = displayNativeSize.height * scaleFactor;
                 break;
             }
-            
         }
     }