@@ -465,32 +465,41 @@ void CMonitor::onDisconnect(bool destroy) {
465465 std::erase_if (g_pCompositor->m_monitors , [&](PHLMONITOR& el) { return el.get () == this ; });
466466}
467467
468- void CMonitor::applyCMType (NCMType::eCMType cmType) {
469- auto oldImageDescription = m_imageDescription;
468+ void CMonitor::applyCMType (NCMType::eCMType cmType, int cmSdrEotf) {
469+ auto oldImageDescription = m_imageDescription;
470+ static auto PSDREOTF = CConfigValue<Hyprlang::INT>(" render:cm_sdr_eotf" );
471+ auto chosenSdrEotf = cmSdrEotf == 0 ? (*PSDREOTF > 0 ? NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22 : NColorManagement::CM_TRANSFER_FUNCTION_SRGB) :
472+ (cmSdrEotf == 1 ? NColorManagement::CM_TRANSFER_FUNCTION_SRGB : NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22);
473+
470474 switch (cmType) {
471- case NCMType::CM_SRGB: m_imageDescription = {}; break ; // assumes SImageDescirption defaults to sRGB
475+ case NCMType::CM_SRGB: m_imageDescription = {. transferFunction = chosenSdrEotf }; break ; // assumes SImageDescription defaults to sRGB
472476 case NCMType::CM_WIDE:
473- m_imageDescription = {.primariesNameSet = true ,
477+ m_imageDescription = {.transferFunction = chosenSdrEotf,
478+ .primariesNameSet = true ,
474479 .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
475480 .primaries = NColorManagement::getPrimaries (NColorManagement::CM_PRIMARIES_BT2020)};
476481 break ;
477482 case NCMType::CM_DCIP3:
478- m_imageDescription = {.primariesNameSet = true ,
483+ m_imageDescription = {.transferFunction = chosenSdrEotf,
484+ .primariesNameSet = true ,
479485 .primariesNamed = NColorManagement::CM_PRIMARIES_DCI_P3,
480486 .primaries = NColorManagement::getPrimaries (NColorManagement::CM_PRIMARIES_DCI_P3)};
481487 break ;
482488 case NCMType::CM_DP3:
483- m_imageDescription = {.primariesNameSet = true ,
489+ m_imageDescription = {.transferFunction = chosenSdrEotf,
490+ .primariesNameSet = true ,
484491 .primariesNamed = NColorManagement::CM_PRIMARIES_DISPLAY_P3,
485492 .primaries = NColorManagement::getPrimaries (NColorManagement::CM_PRIMARIES_DISPLAY_P3)};
486493 break ;
487494 case NCMType::CM_ADOBE:
488- m_imageDescription = {.primariesNameSet = true ,
495+ m_imageDescription = {.transferFunction = chosenSdrEotf,
496+ .primariesNameSet = true ,
489497 .primariesNamed = NColorManagement::CM_PRIMARIES_ADOBE_RGB,
490498 .primaries = NColorManagement::getPrimaries (NColorManagement::CM_PRIMARIES_ADOBE_RGB)};
491499 break ;
492500 case NCMType::CM_EDID:
493- m_imageDescription = {.primariesNameSet = false ,
501+ m_imageDescription = {.transferFunction = chosenSdrEotf,
502+ .primariesNameSet = true ,
494503 .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
495504 .primaries = {
496505 .red = {.x = m_output->parsedEDID .chromaticityCoords ->red .x , .y = m_output->parsedEDID .chromaticityCoords ->red .y },
@@ -868,14 +877,16 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
868877 default : break ;
869878 }
870879
880+ m_sdrEotf = RULE->sdrEotf ;
881+
871882 m_sdrMinLuminance = RULE->sdrMinLuminance ;
872883 m_sdrMaxLuminance = RULE->sdrMaxLuminance ;
873884
874885 m_minLuminance = RULE->minLuminance ;
875886 m_maxLuminance = RULE->maxLuminance ;
876887 m_maxAvgLuminance = RULE->maxAvgLuminance ;
877888
878- applyCMType (m_cmType);
889+ applyCMType (m_cmType, m_sdrEotf );
879890
880891 m_sdrSaturation = RULE->sdrSaturation ;
881892 m_sdrBrightness = RULE->sdrBrightness ;
0 commit comments