summaryrefslogtreecommitdiff
path: root/src/protocols/core/Compositor.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2025-03-26 15:11:19 +0000
committerVaxry <vaxry@vaxry.net>2025-03-26 17:22:21 +0000
commit0cd04bd666665bfdeafc0f55a93e532cd8978827 (patch)
treeb5bd31ee41aff585ab45506278d4d17fee09d3a1 /src/protocols/core/Compositor.cpp
parent1c2b9a9ce3a58c76632834774a4716af1de45fe6 (diff)
surfacestate: track and apply updated state
fixes #9729
Diffstat (limited to 'src/protocols/core/Compositor.cpp')
-rw-r--r--src/protocols/core/Compositor.cpp42
1 files changed, 28 insertions, 14 deletions
diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp
index 2dd374a8..974207a4 100644
--- a/src/protocols/core/Compositor.cpp
+++ b/src/protocols/core/Compositor.cpp
@@ -71,8 +71,8 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : resource(reso
resource->setOnDestroy([this](CWlSurface* r) { destroy(); });
resource->setAttach([this](CWlSurface* r, wl_resource* buffer, int32_t x, int32_t y) {
- pending.offset = {x, y};
- pending.newBuffer = true;
+ pending.offset = {x, y};
+ pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_BUFFER | SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_OFFSET;
if (!buffer) {
pending.buffer.reset();
@@ -119,11 +119,23 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : resource(reso
commitPendingState(pending);
});
- resource->setDamage([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) { pending.damage.add(CBox{x, y, w, h}); });
- resource->setDamageBuffer([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) { pending.bufferDamage.add(CBox{x, y, w, h}); });
+ resource->setDamage([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) {
+ pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_DAMAGE;
+ pending.damage.add(CBox{x, y, w, h});
+ });
+ resource->setDamageBuffer([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) {
+ pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_DAMAGE;
+ pending.bufferDamage.add(CBox{x, y, w, h});
+ });
- resource->setSetBufferScale([this](CWlSurface* r, int32_t scale) { pending.scale = scale; });
- resource->setSetBufferTransform([this](CWlSurface* r, uint32_t tr) { pending.transform = (wl_output_transform)tr; });
+ resource->setSetBufferScale([this](CWlSurface* r, int32_t scale) {
+ pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_SCALE;
+ pending.scale = scale;
+ });
+ resource->setSetBufferTransform([this](CWlSurface* r, uint32_t tr) {
+ pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_TRANSFORM;
+ pending.transform = (wl_output_transform)tr;
+ });
resource->setSetInputRegion([this](CWlSurface* r, wl_resource* region) {
if (!region) {
@@ -131,6 +143,8 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : resource(reso
return;
}
+ pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_INPUT;
+
auto RG = CWLRegionResource::fromResource(region);
pending.input = RG->region;
});
@@ -141,13 +155,18 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : resource(reso
return;
}
+ pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_OPAQUE;
+
auto RG = CWLRegionResource::fromResource(region);
pending.opaque = RG->region;
});
resource->setFrame([this](CWlSurface* r, uint32_t id) { callbacks.emplace_back(makeShared<CWLCallbackResource>(makeShared<CWlCallback>(pClient, 1, id))); });
- resource->setOffset([this](CWlSurface* r, int32_t x, int32_t y) { pending.offset = {x, y}; });
+ resource->setOffset([this](CWlSurface* r, int32_t x, int32_t y) {
+ pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_OFFSET;
+ pending.offset = {x, y};
+ });
}
CWLSurfaceResource::~CWLSurfaceResource() {
@@ -403,13 +422,8 @@ CBox CWLSurfaceResource::extends() {
void CWLSurfaceResource::commitPendingState(SSurfaceState& state) {
auto lastTexture = current.texture;
- if (state.newBuffer) {
- state.newBuffer = false;
- current = state;
- state.damage.clear();
- state.bufferDamage.clear();
- state.buffer.reset();
- }
+ current.updateFrom(state);
+ state.updated = 0;
if (current.buffer) {
if (current.buffer->buffer->isSynchronous())