Skip to content

Commit d05cbc0

Browse files
committed
Monitor (macOS): detect HDR support
1 parent 28d95c9 commit d05cbc0

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ elseif(APPLE)
541541
src/detection/gamepad/gamepad_apple.c
542542
src/detection/media/media_apple.m
543543
src/detection/memory/memory_apple.c
544-
src/detection/monitor/monitor_apple.c
544+
src/detection/monitor/monitor_apple.m
545545
src/detection/opengl/opengl_apple.c
546546
src/detection/os/os_apple.m
547547
src/detection/packages/packages_apple.c

src/detection/monitor/monitor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ typedef struct FFMonitorResult
77
uint32_t height; // native / maximum resolution, in pixels
88
uint32_t physicalWidth; // in mm
99
uint32_t physicalHeight; // in mm
10+
bool hdrCompatible;
1011
} FFMonitorResult;
1112

1213
const char* ffDetectMonitor(FFlist* results);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include "util/apple/ddcci.h"
55
#include "util/edidHelper.h"
66

7+
#import <AppKit/NSScreen.h>
8+
#import <Foundation/Foundation.h>
9+
710
extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import));
811

912
static const char* detectWithDisplayServices(const FFDisplayServerResult* displayServer, FFlist* results)
@@ -31,6 +34,30 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa
3134
CGSize size = CGDisplayScreenSize((CGDirectDisplayID) display->id);
3235
monitor->physicalWidth = (uint32_t) (size.width + 0.5);
3336
monitor->physicalHeight = (uint32_t) (size.height + 0.5);
37+
monitor->hdrCompatible = false;
38+
39+
if (CFDictionaryContainsKey(displayInfo, CFSTR("ReferencePeakHDRLuminance")))
40+
monitor->hdrCompatible = true;
41+
else
42+
{
43+
NSScreen* mainScreen = NSScreen.mainScreen;
44+
if (display->primary)
45+
monitor->hdrCompatible = mainScreen.maximumPotentialExtendedDynamicRangeColorComponentValue > 1;
46+
else
47+
{
48+
for (NSScreen* screen in NSScreen.screens)
49+
{
50+
if (screen == mainScreen) continue;
51+
NSNumber* screenNumber = [screen.deviceDescription valueForKey:@"NSScreenNumber"];
52+
if (screenNumber && screenNumber.longValue == 1)
53+
{
54+
monitor->hdrCompatible = screen.maximumPotentialExtendedDynamicRangeColorComponentValue > 1;
55+
break;
56+
}
57+
}
58+
continue;
59+
}
60+
}
3461
}
3562
}
3663
}
@@ -93,6 +120,7 @@ static const char* detectWithDdcci(FFlist* results)
93120
ffStrbufInit(&display->name);
94121
ffEdidGetName(edidData, &display->name);
95122
ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight);
123+
monitor->hdrCompatible = false;
96124
}
97125
return NULL;
98126
}

0 commit comments

Comments
 (0)