mirror of
https://github.com/quickshell-mirror/quickshell.git
synced 2026-10-27 02:54:36 +00:00
wayland/screencopy: handle buffer creation failures
This commit is contained in:
4 files changed
+30
No files matched your search
@@ -69,6 +69,11 @@ bool WlBufferManager::isReady() const { return this->p->mReady; }
|
||||
qCDebug(logBuffer) << " Format" << format;
|
||||
}
|
||||
|
||||
if (request.width == 0 || request.height == 0) {
|
||||
qCWarning(logBuffer) << "Cannot create zero-sized buffer.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!dmabufDisabled) {
|
||||
if (auto* buf = this->p->dmabuf.createDmabuf(request)) return buf;
|
||||
qCWarning(logBuffer) << "DMA buffer creation failed, falling back to SHM.";
|
||||
|
||||
@@ -103,6 +103,16 @@ void HyprlandScreencopyContext::hyprland_toplevel_export_frame_v1_flags(uint32_t
|
||||
|
||||
void HyprlandScreencopyContext::hyprland_toplevel_export_frame_v1_buffer_done() {
|
||||
auto* backbuffer = this->mSwapchain.createBackbuffer(this->request);
|
||||
|
||||
if (!backbuffer || !backbuffer->buffer()) {
|
||||
qCWarning(logScreencopy) << "Backbuffer creation failed for screencopy. Skipping frame.";
|
||||
|
||||
// Try again. This will be spammy if the compositor continuously sends bad frames.
|
||||
this->destroy();
|
||||
this->captureFrame();
|
||||
return;
|
||||
}
|
||||
|
||||
this->copy(backbuffer->buffer(), this->copiedFirstFrame ? 0 : 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,12 @@ void IccScreencopyContext::doCapture() {
|
||||
auto newBuffer = false;
|
||||
auto* backbuffer = this->mSwapchain.createBackbuffer(this->request, &newBuffer);
|
||||
|
||||
if (!backbuffer || !backbuffer->buffer()) {
|
||||
qCWarning(logIcc) << "Backbuffer creation failed for screencopy. Waiting for updated buffer "
|
||||
"creation parameters before trying again.";
|
||||
return;
|
||||
}
|
||||
|
||||
this->IccCaptureFrame::init(this->IccCaptureSession::create_frame());
|
||||
this->IccCaptureFrame::attach_buffer(backbuffer->buffer());
|
||||
|
||||
|
||||
@@ -111,6 +111,15 @@ void WlrScreencopyContext::zwlr_screencopy_frame_v1_flags(uint32_t flags) {
|
||||
void WlrScreencopyContext::zwlr_screencopy_frame_v1_buffer_done() {
|
||||
auto* backbuffer = this->mSwapchain.createBackbuffer(this->request);
|
||||
|
||||
if (!backbuffer || !backbuffer->buffer()) {
|
||||
qCWarning(logScreencopy) << "Backbuffer creation failed for screencopy. Skipping frame.";
|
||||
|
||||
// Try again. This will be spammy if the compositor continuously sends bad frames.
|
||||
this->destroy();
|
||||
this->captureFrame();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->copiedFirstFrame) {
|
||||
this->copy_with_damage(backbuffer->buffer());
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user