From 4078fcab2ba63d8d67dfa76442390d79fdd9855f Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 8 Feb 2023 19:14:49 +0100 Subject: [PATCH] screencast: Error out if we request a region without outputs It makes for a bad development experience and I don't see a good use case for it right now. If it existed, we can always make sure it works. --- src/plugins/screencast/screencastmanager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/screencast/screencastmanager.cpp b/src/plugins/screencast/screencastmanager.cpp index 75a5d3e66a..5c869abd68 100644 --- a/src/plugins/screencast/screencastmanager.cpp +++ b/src/plugins/screencast/screencastmanager.cpp @@ -179,9 +179,10 @@ void ScreencastManager::streamRegion(KWaylandServer::ScreencastStreamV1Interface stream->setObjectName(rectToString(geometry)); stream->setCursorMode(mode, scale, geometry); - connect(stream, &ScreenCastStream::startStreaming, waylandStream, [geometry, stream, source] { + connect(stream, &ScreenCastStream::startStreaming, waylandStream, [geometry, stream, source, waylandStream] { Compositor::self()->scene()->addRepaint(geometry); + bool found = false; const auto allOutputs = workspace()->outputs(); for (auto output : allOutputs) { if (output->geometry().intersects(geometry)) { @@ -196,8 +197,12 @@ void ScreencastManager::streamRegion(KWaylandServer::ScreencastStreamV1Interface stream->recordFrame(scaleRegion(region.translated(-streamRegion.topLeft()).intersected(streamRegion), source->scale())); }; connect(output, &Output::outputChange, stream, bufferToStream); + found |= true; } } + if (!found) { + waylandStream->sendFailed(i18n("Region outside the workspace")); + } }); integrateStreams(waylandStream, stream); }