summaryrefslogtreecommitdiff
path: root/src/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocols')
-rw-r--r--src/protocols/ColorManagement.cpp13
-rw-r--r--src/protocols/core/Compositor.cpp7
-rw-r--r--src/protocols/core/Compositor.hpp2
3 files changed, 18 insertions, 4 deletions
diff --git a/src/protocols/ColorManagement.cpp b/src/protocols/ColorManagement.cpp
index ada121a7..502fbe45 100644
--- a/src/protocols/ColorManagement.cpp
+++ b/src/protocols/ColorManagement.cpp
@@ -362,6 +362,11 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorMana
m_resource->setGetPreferred([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(SP<CWpColorMana
RESOURCE->m_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(SP<CWpColorMana
RESOURCE->m_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 8e70fba0..58d7810c 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 <cstring>
+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 26b5a27b..8f1f8064 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<CWLSurfaceResource> findFirstPreorder(std::function<bool(SP<CWLSurfaceResource>)> 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