Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3cb43e0

Browse files
committedApr 6, 2025
use queue for comitted pending surface states like proto says
"The content update is placed in a queue until it becomes active." - wl_surface::commit
1 parent 9fbd34d commit 3cb43e0

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
 

‎src/protocols/core/Compositor.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : resource(reso
115115

116116
events.precommit.emit();
117117
if (pending.rejected) {
118+
pending.rejected = false;
118119
dropPendingBuffer();
119120
return;
120121
}
@@ -129,15 +130,20 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : resource(reso
129130
}
130131

131132
// save state while we wait for buffer to become ready
132-
const auto& state = pendingStates.emplace_back(makeUnique<SSurfaceState>(pending));
133+
const auto& state = pendingStates.emplace(makeUnique<SSurfaceState>(pending));
133134
pending.reset();
134135

135136
auto whenReadable = [this, surf = self, state = WP<SSurfaceState>(pendingStates.back())] {
136137
if (!surf || state.expired())
137138
return;
138139

139-
surf->commitState(*state);
140-
std::erase(pendingStates, state);
140+
while (!pendingStates.empty() && pendingStates.front() != state) {
141+
commitState(*pendingStates.front());
142+
pendingStates.pop();
143+
}
144+
145+
commitState(*pendingStates.front());
146+
pendingStates.pop();
141147
};
142148

143149
if (state->updated.acquire) {

‎src/protocols/core/Compositor.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include <vector>
12+
#include <queue>
1213
#include <cstdint>
1314
#include "../WaylandProtocol.hpp"
1415
#include "../../render/Texture.hpp"
@@ -87,7 +88,7 @@ class CWLSurfaceResource {
8788
} events;
8889

8990
SSurfaceState current, pending;
90-
std::vector<UP<SSurfaceState>> pendingStates;
91+
std::queue<UP<SSurfaceState>> pendingStates;
9192

9293
std::vector<SP<CWLCallbackResource>> callbacks;
9394
WP<CWLSurfaceResource> self;

0 commit comments

Comments
 (0)
Please sign in to comment.