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.
This commit is contained in:
Aleix Pol 2023-02-08 19:14:49 +01:00
parent 852d10ddd7
commit 4078fcab2b

View file

@ -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);
}