From 837903e8458619646961a29c34df07ed1d43c645 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 9 Nov 2024 21:27:16 +0800 Subject: [PATCH] DisplayServer: fix deprecation warnings --- src/detection/displayserver/displayserver_apple.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index d51584923..520750110 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -36,6 +36,8 @@ static void detectDisplays(FFDisplayServerResult* ds) if (refreshRate == 0) { + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" CVDisplayLinkRef link; if(CVDisplayLinkCreateWithCGDisplay(screen, &link) == kCVReturnSuccess) { @@ -44,6 +46,7 @@ static void detectDisplays(FFDisplayServerResult* ds) refreshRate = time.timeScale / (double) time.timeValue; //59.97... CVDisplayLinkRelease(link); } + #pragma clang diagnostic pop } ffStrbufClear(&buffer); @@ -99,6 +102,10 @@ static void detectDisplays(FFDisplayServerResult* ds) ); if (display) { + #ifndef MAC_OS_X_VERSION_10_11 + FF_CFTYPE_AUTO_RELEASE CFStringRef pe = CGDisplayModeCopyPixelEncoding(mode); + if (pe) display->bitDepth = (uint8_t) (CFStringGetLength(pe) - CFStringFind(pe, CFSTR("B"), 0).location); + #else // https://stackoverflow.com/a/33519316/9976392 // Also shitty, but better than parsing `CFCopyDescription(mode)` CFDictionaryRef dict = (CFDictionaryRef) *((int64_t *)mode + 2); @@ -108,6 +115,7 @@ static void detectDisplays(FFDisplayServerResult* ds) ffCfDictGetInt(dict, kCGDisplayBitsPerSample, &bitDepth); display->bitDepth = (uint8_t) bitDepth; } + #endif if (display->type == FF_DISPLAY_TYPE_BUILTIN) display->hdrStatus = CFDictionaryContainsKey(displayInfo, CFSTR("ReferencePeakHDRLuminance"))