@@ -419,6 +419,58 @@ void CMonitor::onDisconnect(bool destroy) {
419
419
std::erase_if (g_pCompositor->m_monitors , [&](PHLMONITOR& el) { return el.get () == this ; });
420
420
}
421
421
422
+ void CMonitor::applyCMType (eCMType cmType) {
423
+ switch (cmType) {
424
+ case CM_SRGB: m_imageDescription = {}; break ; // assumes SImageDescirption defaults to sRGB
425
+ case CM_WIDE:
426
+ m_imageDescription = {.primariesNameSet = true ,
427
+ .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
428
+ .primaries = NColorManagement::getPrimaries (NColorManagement::CM_PRIMARIES_BT2020)};
429
+ break ;
430
+ case CM_EDID:
431
+ m_imageDescription = {.primariesNameSet = false ,
432
+ .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
433
+ .primaries = {
434
+ .red = {.x = m_output->parsedEDID .chromaticityCoords ->red .x , .y = m_output->parsedEDID .chromaticityCoords ->red .y },
435
+ .green = {.x = m_output->parsedEDID .chromaticityCoords ->green .x , .y = m_output->parsedEDID .chromaticityCoords ->green .y },
436
+ .blue = {.x = m_output->parsedEDID .chromaticityCoords ->blue .x , .y = m_output->parsedEDID .chromaticityCoords ->blue .y },
437
+ .white = {.x = m_output->parsedEDID .chromaticityCoords ->white .x , .y = m_output->parsedEDID .chromaticityCoords ->white .y },
438
+ }};
439
+ break ;
440
+ case CM_HDR:
441
+ m_imageDescription = {.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ,
442
+ .primariesNameSet = true ,
443
+ .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
444
+ .primaries = NColorManagement::getPrimaries (NColorManagement::CM_PRIMARIES_BT2020),
445
+ .luminances = {.min = 0 , .max = 10000 , .reference = 203 }};
446
+ break ;
447
+ case CM_HDR_EDID:
448
+ m_imageDescription = {.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ,
449
+ .primariesNameSet = false ,
450
+ .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
451
+ .primaries = m_output->parsedEDID .chromaticityCoords .has_value () ?
452
+ NColorManagement::SPCPRimaries{
453
+ .red = {.x = m_output->parsedEDID .chromaticityCoords ->red .x , .y = m_output->parsedEDID .chromaticityCoords ->red .y },
454
+ .green = {.x = m_output->parsedEDID .chromaticityCoords ->green .x , .y = m_output->parsedEDID .chromaticityCoords ->green .y },
455
+ .blue = {.x = m_output->parsedEDID .chromaticityCoords ->blue .x , .y = m_output->parsedEDID .chromaticityCoords ->blue .y },
456
+ .white = {.x = m_output->parsedEDID .chromaticityCoords ->white .x , .y = m_output->parsedEDID .chromaticityCoords ->white .y },
457
+ } :
458
+ NColorManagement::getPrimaries (NColorManagement::CM_PRIMARIES_BT2020),
459
+ .luminances = {.min = m_output->parsedEDID .hdrMetadata ->desiredContentMinLuminance ,
460
+ .max = m_output->parsedEDID .hdrMetadata ->desiredContentMaxLuminance ,
461
+ .reference = m_output->parsedEDID .hdrMetadata ->desiredMaxFrameAverageLuminance }};
462
+
463
+ break ;
464
+ default : UNREACHABLE ();
465
+ }
466
+ if (m_minLuminance >= 0 )
467
+ m_imageDescription.luminances .min = m_minLuminance;
468
+ if (m_maxLuminance >= 0 )
469
+ m_imageDescription.luminances .max = m_maxLuminance;
470
+ if (m_maxAvgLuminance >= 0 )
471
+ m_imageDescription.luminances .reference = m_maxAvgLuminance;
472
+ }
473
+
422
474
bool CMonitor::applyMonitorRule (SMonitorRule* pMonitorRule, bool force) {
423
475
424
476
static auto PDISABLESCALECHECKS = CConfigValue<Hyprlang::INT>(" debug:disable_scale_checks" );
@@ -748,62 +800,15 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
748
800
case CM_HDR_EDID: m_cmType = supportsHDR () ? m_cmType : CM_SRGB; break ;
749
801
default : break ;
750
802
}
751
- switch (m_cmType) {
752
- case CM_SRGB: m_imageDescription = {}; break ; // assumes SImageDescirption defaults to sRGB
753
- case CM_WIDE:
754
- m_imageDescription = {.primariesNameSet = true ,
755
- .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
756
- .primaries = NColorManagement::getPrimaries (NColorManagement::CM_PRIMARIES_BT2020)};
757
- break ;
758
- case CM_EDID:
759
- m_imageDescription = {.primariesNameSet = false ,
760
- .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
761
- .primaries = {
762
- .red = {.x = m_output->parsedEDID .chromaticityCoords ->red .x , .y = m_output->parsedEDID .chromaticityCoords ->red .y },
763
- .green = {.x = m_output->parsedEDID .chromaticityCoords ->green .x , .y = m_output->parsedEDID .chromaticityCoords ->green .y },
764
- .blue = {.x = m_output->parsedEDID .chromaticityCoords ->blue .x , .y = m_output->parsedEDID .chromaticityCoords ->blue .y },
765
- .white = {.x = m_output->parsedEDID .chromaticityCoords ->white .x , .y = m_output->parsedEDID .chromaticityCoords ->white .y },
766
- }};
767
- break ;
768
- case CM_HDR:
769
- m_imageDescription = {.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ,
770
- .primariesNameSet = true ,
771
- .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
772
- .primaries = NColorManagement::getPrimaries (NColorManagement::CM_PRIMARIES_BT2020),
773
- .luminances = {.min = 0 , .max = 10000 , .reference = 203 }};
774
- break ;
775
- case CM_HDR_EDID:
776
- m_imageDescription = {.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ,
777
- .primariesNameSet = false ,
778
- .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
779
- .primaries = m_output->parsedEDID .chromaticityCoords .has_value () ?
780
- NColorManagement::SPCPRimaries{
781
- .red = {.x = m_output->parsedEDID .chromaticityCoords ->red .x , .y = m_output->parsedEDID .chromaticityCoords ->red .y },
782
- .green = {.x = m_output->parsedEDID .chromaticityCoords ->green .x , .y = m_output->parsedEDID .chromaticityCoords ->green .y },
783
- .blue = {.x = m_output->parsedEDID .chromaticityCoords ->blue .x , .y = m_output->parsedEDID .chromaticityCoords ->blue .y },
784
- .white = {.x = m_output->parsedEDID .chromaticityCoords ->white .x , .y = m_output->parsedEDID .chromaticityCoords ->white .y },
785
- } :
786
- NColorManagement::getPrimaries (NColorManagement::CM_PRIMARIES_BT2020),
787
- .luminances = {.min = m_output->parsedEDID .hdrMetadata ->desiredContentMinLuminance ,
788
- .max = m_output->parsedEDID .hdrMetadata ->desiredContentMaxLuminance ,
789
- .reference = m_output->parsedEDID .hdrMetadata ->desiredMaxFrameAverageLuminance }};
790
-
791
- break ;
792
- default : UNREACHABLE ();
793
- }
794
803
795
804
m_sdrMinLuminance = RULE->sdrMinLuminance ;
796
805
m_sdrMaxLuminance = RULE->sdrMaxLuminance ;
797
806
798
- m_minLuminance = RULE->minLuminance ;
799
- if (m_minLuminance >= 0 )
800
- m_imageDescription.luminances .min = m_minLuminance;
801
- m_maxLuminance = RULE->maxLuminance ;
802
- if (m_maxLuminance >= 0 )
803
- m_imageDescription.luminances .max = m_maxLuminance;
807
+ m_minLuminance = RULE->minLuminance ;
808
+ m_maxLuminance = RULE->maxLuminance ;
804
809
m_maxAvgLuminance = RULE->maxAvgLuminance ;
805
- if (m_maxAvgLuminance >= 0 )
806
- m_imageDescription. luminances . reference = m_maxAvgLuminance ;
810
+
811
+ applyCMType (m_cmType) ;
807
812
if (oldImageDescription != m_imageDescription)
808
813
PROTO::colorManagement->onMonitorImageDescriptionChanged (m_self);
809
814
0 commit comments