diff --git a/src/protocols/ColorManagement.cpp b/src/protocols/ColorManagement.cpp index ada121a79..502fbe452 100644 --- a/src/protocols/ColorManagement.cpp +++ b/src/protocols/ColorManagement.cpp @@ -362,6 +362,11 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SPsetGetPreferred([this](CWpColorManagementSurfaceFeedbackV1* r, uint32_t id) { LOGM(TRACE, "Get preferred for id {}", id); + if (m_surface.expired()) { + r->error(WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_ERROR_INERT, "Surface is inert"); + return; + } + if (m_currentPreferred.valid()) PROTO::colorManagement->destroyResource(m_currentPreferred.get()); @@ -377,15 +382,15 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SPm_self = RESOURCE; m_currentPreferred = RESOURCE; - m_currentPreferred->m_settings = g_pCompositor->getPreferredImageDescription(); + m_currentPreferred->m_settings = m_surface->getPreferredImageDescription(); RESOURCE->resource()->sendReady(m_currentPreferred->m_settings.updateId()); }); m_resource->setGetPreferredParametric([this](CWpColorManagementSurfaceFeedbackV1* r, uint32_t id) { LOGM(TRACE, "Get preferred for id {}", id); - if (!PROTO::colorManagement->m_debug) { - r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "Parametric descriptions are not supported"); + if (m_surface.expired()) { + r->error(WP_COLOR_MANAGEMENT_SURFACE_FEEDBACK_V1_ERROR_INERT, "Surface is inert"); return; } @@ -404,7 +409,7 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SPm_self = RESOURCE; m_currentPreferred = RESOURCE; - m_currentPreferred->m_settings = g_pCompositor->getPreferredImageDescription(); + m_currentPreferred->m_settings = m_surface->getPreferredImageDescription(); if (!PROTO::colorManagement->m_debug && m_currentPreferred->m_settings.icc.fd) { LOGM(ERR, "FIXME: parse icc profile"); r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "ICC profiles are not supported"); diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp index 8e70fba0e..58d7810c4 100644 --- a/src/protocols/core/Compositor.cpp +++ b/src/protocols/core/Compositor.cpp @@ -1,4 +1,5 @@ #include "Compositor.hpp" +#include "../../Compositor.hpp" #include "Output.hpp" #include "Seat.hpp" #include "../types/WLBuffer.hpp" @@ -17,6 +18,8 @@ #include "render/Texture.hpp" #include +using namespace NColorManagement; + class CDefaultSurfaceRole : public ISurfaceRole { public: virtual eSurfaceRole role() { @@ -535,6 +538,10 @@ void CWLSurfaceResource::commitState(SSurfaceState& state) { dropCurrentBuffer(); } +SImageDescription CWLSurfaceResource::getPreferredImageDescription() { + return m_enteredOutputs.size() == 1 ? m_enteredOutputs[0]->m_imageDescription : g_pCompositor->getPreferredImageDescription(); +} + void CWLSurfaceResource::updateCursorShm(CRegion damage) { if (damage.empty()) return; diff --git a/src/protocols/core/Compositor.hpp b/src/protocols/core/Compositor.hpp index 26b5a27b0..8f1f8064a 100644 --- a/src/protocols/core/Compositor.hpp +++ b/src/protocols/core/Compositor.hpp @@ -18,6 +18,7 @@ #include "../../helpers/math/Math.hpp" #include "../../helpers/time/Time.hpp" #include "../types/Buffer.hpp" +#include "../types/ColorManagement.hpp" #include "../types/SurfaceRole.hpp" #include "../types/SurfaceState.hpp" @@ -107,6 +108,7 @@ class CWLSurfaceResource { SP findFirstPreorder(std::function)> fn); void presentFeedback(const Time::steady_tp& when, PHLMONITOR pMonitor, bool discarded = false); void commitState(SSurfaceState& state); + NColorManagement::SImageDescription getPreferredImageDescription(); // returns a pair: found surface (null if not found) and surface local coords. // localCoords param is relative to 0,0 of this surface