protocols: Support wp color management proto (#9444)

Adds support for the recently merged w-p CM protocol alongside the (now deprecated) old CM WIP protocols
This commit is contained in:
UjinT34 2025-02-26 17:56:37 +03:00 committed by GitHub
parent f0850905f0
commit 6787fe8933
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 1561 additions and 276 deletions

View file

@ -306,6 +306,23 @@ void CWLSurfaceResource::breadthfirst(std::function<void(SP<CWLSurfaceResource>,
bfHelper(surfs, fn, data);
}
SP<CWLSurfaceResource> CWLSurfaceResource::findFirstPreorderHelper(SP<CWLSurfaceResource> root, std::function<bool(SP<CWLSurfaceResource>)> fn) {
if (fn(root))
return root;
for (auto const& sub : root->subsurfaces) {
if (sub.expired() || sub->surface.expired())
continue;
const auto found = findFirstPreorderHelper(sub->surface.lock(), fn);
if (found)
return found;
}
return nullptr;
}
SP<CWLSurfaceResource> CWLSurfaceResource::findFirstPreorder(std::function<bool(SP<CWLSurfaceResource>)> fn) {
return findFirstPreorderHelper(self.lock(), fn);
}
std::pair<SP<CWLSurfaceResource>, Vector2D> CWLSurfaceResource::at(const Vector2D& localCoords, bool allowsInput) {
std::vector<std::pair<SP<CWLSurfaceResource>, Vector2D>> surfs;
breadthfirst([&surfs](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) { surfs.emplace_back(std::make_pair<>(surf, offset)); }, &surfs);

View file

@ -127,6 +127,7 @@ class CWLSurfaceResource {
WP<CContentType> contentType;
void breadthfirst(std::function<void(SP<CWLSurfaceResource>, const Vector2D&, void*)> fn, void* data);
SP<CWLSurfaceResource> findFirstPreorder(std::function<bool(SP<CWLSurfaceResource>)> fn);
CRegion accumulateCurrentBufferDamage();
void presentFeedback(timespec* when, PHLMONITOR pMonitor, bool discarded = false);
void lockPendingState();
@ -142,17 +143,18 @@ class CWLSurfaceResource {
// this is for cursor dumb copy. Due to our (and wayland's...) architecture,
// this stupid-ass hack is used
WP<IHLBuffer> lastBuffer;
WP<IHLBuffer> lastBuffer;
int stateLocks = 0;
int stateLocks = 0;
void destroy();
void releaseBuffers(bool onlyCurrent = true);
void dropPendingBuffer();
void dropCurrentBuffer();
void commitPendingState();
void bfHelper(std::vector<SP<CWLSurfaceResource>> const& nodes, std::function<void(SP<CWLSurfaceResource>, const Vector2D&, void*)> fn, void* data);
void updateCursorShm(CRegion damage = CBox{0, 0, INT16_MAX, INT16_MAX});
void destroy();
void releaseBuffers(bool onlyCurrent = true);
void dropPendingBuffer();
void dropCurrentBuffer();
void commitPendingState();
void bfHelper(std::vector<SP<CWLSurfaceResource>> const& nodes, std::function<void(SP<CWLSurfaceResource>, const Vector2D&, void*)> fn, void* data);
SP<CWLSurfaceResource> findFirstPreorderHelper(SP<CWLSurfaceResource> root, std::function<bool(SP<CWLSurfaceResource>)> fn);
void updateCursorShm(CRegion damage = CBox{0, 0, INT16_MAX, INT16_MAX});
friend class CWLPointerResource;
};