Skip to content

Commit

Permalink
[Windows] Fix detection of SDR screens for Win11 22H2 and 23H2.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrystalP committed Dec 21, 2024
1 parent 22a9ed0 commit 0c734a8
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions xbmc/platform/win32/WIN32Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,11 +1565,27 @@ HDR_STATUS CWIN32Util::GetWindowsHDRStatus()

if (ERROR_SUCCESS == DisplayConfigGetDeviceInfo(&getColorInfo.header))
{
if (getColorInfo.advancedColorEnabled)
hdrEnabled = true;

if (getColorInfo.advancedColorSupported)
// DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO documentation is lacking and field
// names are confusing. Through experimentation and deductions from equivalent WinRT API:
//
// SDR screen, advanced color not supported (Win 10, Win 11 < 22H2)
// > advancedColorSupported = 0 and wideColorEnforced = 0
// SDR screen, advanced color is supported (Win 11 >= 22H2)
// > advancedColorSupported = 1 and wideColorEnforced = 1
// HDR screen
// > advancedColorSupported = 1 and wideColorEnforced = 0
//
// advancedColorForceDisabled: maybe equivalent of advancedColorLimitedByPolicy?
//
// advancedColorEnabled = 1:
// For HDR screens means HDR is on
// For SDR screens means ACM (Automatic Color Management, Win 11 >= 22H2) is on

if (getColorInfo.advancedColorSupported && !getColorInfo.wideColorEnforced)
hdrSupported = true;

if (hdrSupported && getColorInfo.advancedColorEnabled)
hdrEnabled = true;
}

if (g_hWnd != nullptr)
Expand Down

0 comments on commit 0c734a8

Please sign in to comment.