diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index d2e87ecf2..d05eb8b1e 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -8,10 +8,11 @@ #include #include +#ifdef MAC_OS_X_VERSION_10_15 extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import)); -#ifndef MAC_OS_X_VERSION_10_15 -#import -extern CFDictionaryRef CoreDisplay_IODisplayCreateInfoDictionary(io_service_t framebuffer, IOOptionBits options) __attribute__((weak_import)); +extern Boolean CoreDisplay_Display_IsHDRModeEnabled(CGDirectDisplayID display) __attribute__((weak_import)); +#else +#include #endif static void detectDisplays(FFDisplayServerResult* ds) @@ -43,30 +44,22 @@ static void detectDisplays(FFDisplayServerResult* ds) } FF_STRBUF_AUTO_DESTROY name = ffStrbufCreate(); + CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = NULL; #ifdef MAC_OS_X_VERSION_10_15 if(CoreDisplay_DisplayCreateInfoDictionary) - { - CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_DisplayCreateInfoDictionary(screen); - if(displayInfo) - { - CFDictionaryRef productNames; - if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames)) - ffCfDictGetString(productNames, CFSTR("en_US"), &name); - } - } + displayInfo = CoreDisplay_DisplayCreateInfoDictionary(screen); #else - if(CoreDisplay_IODisplayCreateInfoDictionary) { io_service_t servicePort = CGDisplayIOServicePort(screen); - CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_IODisplayCreateInfoDictionary(servicePort, kIODisplayOnlyPreferredName); - if(displayInfo) - { - CFDictionaryRef productNames; - if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames)) - ffCfDictGetString(productNames, CFSTR("en_US"), &name); - } + displayInfo = IODisplayCreateInfoDictionary(servicePort, kIODisplayOnlyPreferredName); } #endif + if(displayInfo) + { + CFDictionaryRef productNames; + if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames)) + ffCfDictGetString(productNames, CFSTR("en_US"), &name); + } CGSize size = CGDisplayScreenSize(screen); @@ -95,6 +88,11 @@ static void detectDisplays(FFDisplayServerResult* ds) ffCfDictGetInt(dict, kCGDisplayBitsPerSample, &bitDepth); display->bitDepth = (uint8_t) bitDepth; } + + if (CoreDisplay_Display_IsHDRModeEnabled) + { + display->hdrEnabled = CoreDisplay_Display_IsHDRModeEnabled(screen); + } } CGDisplayModeRelease(mode); } diff --git a/src/detection/monitor/monitor_apple.m b/src/detection/monitor/monitor_apple.m index 2c4a1e3c2..70d71eeb6 100644 --- a/src/detection/monitor/monitor_apple.m +++ b/src/detection/monitor/monitor_apple.m @@ -7,11 +7,10 @@ #import #import +#ifdef MAC_OS_X_VERSION_10_15 extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import)); - -#ifndef MAC_OS_X_VERSION_10_15 -#import -extern CFDictionaryRef CoreDisplay_IODisplayCreateInfoDictionary(io_service_t framebuffer, IOOptionBits options) __attribute__((weak_import)); +#else +#include #endif static bool detectHdrSupportWithNSScreen(FFDisplayResult* display) @@ -57,7 +56,7 @@ const char* ffDetectMonitor(FFlist* results) CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_DisplayCreateInfoDictionary((CGDirectDisplayID) display->id); #else io_service_t servicePort = CGDisplayIOServicePort((CGDirectDisplayID) display->id); - CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_IODisplayCreateInfoDictionary(servicePort, kIODisplayOnlyPreferredName); + CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = IODisplayCreateInfoDictionary(servicePort, kIODisplayOnlyPreferredName); #endif if(!displayInfo) continue; @@ -67,7 +66,7 @@ const char* ffDetectMonitor(FFlist* results) uint8_t edidData[128] = {}; uint32_t edidLength = 0; - if (ffCfDictGetData(displayInfo, CFSTR("IODisplayEDID"), 0, sizeof(edidData), edidData, &edidLength) == NULL) + if (ffCfDictGetData(displayInfo, CFSTR(kIODisplayEDIDKey), 0, sizeof(edidData), edidData, &edidLength) == NULL) { uint32_t width, height; ffEdidGetPhysicalResolution(edidData, &width, &height);