From ab096b7e784a84015633b0ca1d5c63095444cbe1 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sat, 26 Jul 2025 00:09:28 -0700 Subject: [PATCH] wayland/screencopy: reset buffer requests between frames Prevents buffer requests from collecting a huge set of duplicate dmabuf and shm formats. --- src/wayland/buffer/manager.cpp | 5 ++++- src/wayland/buffer/manager.hpp | 2 ++ .../screencopy/hyprland_screencopy/hyprland_screencopy.cpp | 2 ++ src/wayland/screencopy/wlr_screencopy/wlr_screencopy.cpp | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wayland/buffer/manager.cpp b/src/wayland/buffer/manager.cpp index c7448df8..6bbdf292 100644 --- a/src/wayland/buffer/manager.cpp +++ b/src/wayland/buffer/manager.cpp @@ -22,6 +22,8 @@ namespace { QS_LOGGING_CATEGORY(logBuffer, "quickshell.wayland.buffer", QtWarningMsg); } +void WlBufferRequest::reset() { *this = WlBufferRequest(); } + WlBuffer* WlBufferSwapchain::createBackbuffer(const WlBufferRequest& request, bool* newBuffer) { auto& buffer = this->presentSecondBuffer ? this->buffer1 : this->buffer2; @@ -53,7 +55,8 @@ bool WlBufferManager::isReady() const { return this->p->mReady; } << " (disabled: " << dmabufDisabled << ')'; for (const auto& [format, modifiers]: request.dmabuf.formats) { - qCDebug(logBuffer) << " Format" << dmabuf::FourCCStr(format); + qCDebug(logBuffer).nospace() << " Format " << dmabuf::FourCCStr(format) + << (modifiers.length() == 0 ? " (No modifiers specified)" : ""); for (const auto& modifier: modifiers) { qCDebug(logBuffer) << " Explicit Modifier" << dmabuf::FourCCModStr(modifier); diff --git a/src/wayland/buffer/manager.hpp b/src/wayland/buffer/manager.hpp index b521e89e..8abc218c 100644 --- a/src/wayland/buffer/manager.hpp +++ b/src/wayland/buffer/manager.hpp @@ -68,6 +68,8 @@ struct WlBufferRequest { dev_t device = 0; StackList formats; } dmabuf; + + void reset(); }; class WlBuffer { diff --git a/src/wayland/screencopy/hyprland_screencopy/hyprland_screencopy.cpp b/src/wayland/screencopy/hyprland_screencopy/hyprland_screencopy.cpp index b8aef961..5268f665 100644 --- a/src/wayland/screencopy/hyprland_screencopy/hyprland_screencopy.cpp +++ b/src/wayland/screencopy/hyprland_screencopy/hyprland_screencopy.cpp @@ -64,6 +64,8 @@ void HyprlandScreencopyContext::onToplevelDestroyed() { void HyprlandScreencopyContext::captureFrame() { if (this->object()) return; + this->request.reset(); + this->init(this->manager->capture_toplevel_with_wlr_toplevel_handle( this->paintCursors ? 1 : 0, this->handle->object() diff --git a/src/wayland/screencopy/wlr_screencopy/wlr_screencopy.cpp b/src/wayland/screencopy/wlr_screencopy/wlr_screencopy.cpp index f4d8c48d..c7a11a70 100644 --- a/src/wayland/screencopy/wlr_screencopy/wlr_screencopy.cpp +++ b/src/wayland/screencopy/wlr_screencopy/wlr_screencopy.cpp @@ -65,6 +65,8 @@ void WlrScreencopyContext::onScreenDestroyed() { void WlrScreencopyContext::captureFrame() { if (this->object()) return; + this->request.reset(); + if (this->region.isEmpty()) { this->init(manager->capture_output(this->paintCursors ? 1 : 0, screen->output())); } else {