Skip to content

Commit 53d389e

Browse files
committed
wayland/screencopy: reset buffer requests between frames
Prevents buffer requests from collecting a huge set of duplicate dmabuf and shm formats.
1 parent 448623d commit 53d389e

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

src/wayland/buffer/manager.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ namespace {
2222
QS_LOGGING_CATEGORY(logBuffer, "quickshell.wayland.buffer", QtWarningMsg);
2323
}
2424

25+
void WlBufferRequest::reset() { *this = WlBufferRequest(); }
26+
2527
WlBuffer* WlBufferSwapchain::createBackbuffer(const WlBufferRequest& request, bool* newBuffer) {
2628
auto& buffer = this->presentSecondBuffer ? this->buffer1 : this->buffer2;
2729

@@ -53,7 +55,8 @@ bool WlBufferManager::isReady() const { return this->p->mReady; }
5355
<< " (disabled: " << dmabufDisabled << ')';
5456

5557
for (const auto& [format, modifiers]: request.dmabuf.formats) {
56-
qCDebug(logBuffer) << " Format" << dmabuf::FourCCStr(format);
58+
qCDebug(logBuffer).nospace() << " Format " << dmabuf::FourCCStr(format)
59+
<< (modifiers.length() == 0 ? " (No modifiers specified)" : "");
5760

5861
for (const auto& modifier: modifiers) {
5962
qCDebug(logBuffer) << " Explicit Modifier" << dmabuf::FourCCModStr(modifier);

src/wayland/buffer/manager.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ struct WlBufferRequest {
6868
dev_t device = 0;
6969
StackList<DmaFormat, 1> formats;
7070
} dmabuf;
71+
72+
void reset();
7173
};
7274

7375
class WlBuffer {

src/wayland/screencopy/hyprland_screencopy/hyprland_screencopy.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ void HyprlandScreencopyContext::onToplevelDestroyed() {
6464
void HyprlandScreencopyContext::captureFrame() {
6565
if (this->object()) return;
6666

67+
this->request.reset();
68+
6769
this->init(this->manager->capture_toplevel_with_wlr_toplevel_handle(
6870
this->paintCursors ? 1 : 0,
6971
this->handle->object()

src/wayland/screencopy/image_copy_capture/image_copy_capture.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ void IccScreencopyContext::doCapture() {
117117
auto newBuffer = false;
118118
auto* backbuffer = this->mSwapchain.createBackbuffer(this->request, &newBuffer);
119119

120+
this->request.reset();
121+
120122
this->IccCaptureFrame::init(this->IccCaptureSession::create_frame());
121123
this->IccCaptureFrame::attach_buffer(backbuffer->buffer());
122124

src/wayland/screencopy/wlr_screencopy/wlr_screencopy.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ void WlrScreencopyContext::onScreenDestroyed() {
6565
void WlrScreencopyContext::captureFrame() {
6666
if (this->object()) return;
6767

68+
this->request.reset();
69+
6870
if (this->region.isEmpty()) {
6971
this->init(manager->capture_output(this->paintCursors ? 1 : 0, screen->output()));
7072
} else {

0 commit comments

Comments
 (0)