diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 8c7566e2f90..d9364e881d6 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -191,6 +191,7 @@ class CMonitor { bool m_bEnabled = false; bool m_bRenderingInitPassed = false; + WP m_previousFSWindow; // For the list lookup diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 6c77b27a90f..6b9f25f68ff 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1459,12 +1459,6 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) { if (inFD >= 0) pMonitor->output->state->setExplicitInFence(inFD); - static auto PWIDE = CConfigValue("experimental:wide_color_gamut"); - if (pMonitor->output->state->state().wideColorGamut != *PWIDE) { - Debug::log(TRACE, "Setting wide color gamut {}", *PWIDE ? "on" : "off"); - pMonitor->output->state->setWideColorGamut(*PWIDE); - } - static auto PHDR = CConfigValue("experimental:hdr"); const bool SUPPORTSPQ = pMonitor->output->parsedEDID.hdrMetadata.has_value() ? pMonitor->output->parsedEDID.hdrMetadata->supportsPQ : false; @@ -1474,18 +1468,35 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) { const auto WINDOW = pMonitor->activeWorkspace->getFullscreenWindow(); const auto SURF = WINDOW->m_pWLSurface->resource(); if (SURF->colorManagement.valid() && SURF->colorManagement->hasImageDescription()) { - bool needsHdrMetadataUpdate = SURF->colorManagement->needsHdrMetadataUpdate() || m_previousFSWindow != WINDOW; + bool needsHdrMetadataUpdate = SURF->colorManagement->needsHdrMetadataUpdate() || pMonitor->m_previousFSWindow != WINDOW; if (SURF->colorManagement->needsHdrMetadataUpdate()) SURF->colorManagement->setHDRMetadata(createHDRMetadata(SURF->colorManagement.get()->imageDescription(), pMonitor->output->parsedEDID)); if (needsHdrMetadataUpdate) pMonitor->output->state->setHDRMetadata(SURF->colorManagement->hdrMetadata()); } else if ((pMonitor->output->state->state().hdrMetadata.hdmi_metadata_type1.eotf == 2) != *PHDR) pMonitor->output->state->setHDRMetadata(*PHDR ? createHDRMetadata(2, pMonitor->output->parsedEDID) : createHDRMetadata(0, pMonitor->output->parsedEDID)); - m_previousFSWindow = WINDOW; + pMonitor->m_previousFSWindow = WINDOW; } else { if ((pMonitor->output->state->state().hdrMetadata.hdmi_metadata_type1.eotf == 2) != *PHDR) pMonitor->output->state->setHDRMetadata(*PHDR ? createHDRMetadata(2, pMonitor->output->parsedEDID) : createHDRMetadata(0, pMonitor->output->parsedEDID)); - m_previousFSWindow.reset(); + pMonitor->m_previousFSWindow.reset(); + } + } + + static auto PWIDE = CConfigValue("experimental:wide_color_gamut"); + const bool needsWCG = *PWIDE || pMonitor->output->state->state().hdrMetadata.hdmi_metadata_type1.eotf == 2; + if (pMonitor->output->state->state().wideColorGamut != needsWCG) { + Debug::log(TRACE, "Setting wide color gamut {}", needsWCG ? "on" : "off"); + pMonitor->output->state->setWideColorGamut(needsWCG); + + // FIXME do not trust enabled10bit, auto switch to 10bit and back if needed + if (needsWCG && !pMonitor->enabled10bit) { + Debug::log(WARN, "Wide color gamut is enabled but the display is not in 10bit mode"); + static bool shown = false; + if (!shown) { + g_pHyprNotificationOverlay->addNotification("Wide color gamut is enabled but the display is not in 10bit mode", CHyprColor{}, 15000, ICON_WARNING); + shown = true; + } } } diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp index 8b4988c33ed..cee0e7ce508 100644 --- a/src/render/Renderer.hpp +++ b/src/render/Renderer.hpp @@ -129,7 +129,6 @@ class CHyprRenderer { bool commitPendingAndDoExplicitSync(PHLMONITOR pMonitor); - WP m_previousFSWindow; bool m_bCursorHidden = false; bool m_bCursorHasSurface = false; SP m_pCurrentRenderbuffer = nullptr;