Commit 2aa7431b authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

ScreenCast: Make sure we close sessions when all streams are done


(cherry picked from commit 65c7d5a3)
parent b78f6b79
Pipeline #237944 canceled with stage
......@@ -14,6 +14,7 @@
#include <QDBusMessage>
#include <QDBusPendingCall>
#include <QDBusPendingCallWatcher>
#include <screencast_debug.h>
static QMap<QString, Session *> sessionList;
......@@ -204,3 +205,28 @@ void RemoteDesktopSession::setScreenSharingEnabled(bool enabled)
{
m_screenSharingEnabled = enabled;
}
void ScreenCastSession::setStreams(const WaylandIntegration::Streams &streams)
{
m_streams = streams;
for (const auto &s : streams) {
connect(s.stream, &ScreencastingStream::closed, this, &ScreenCastSession::streamClosed);
connect(s.stream, &ScreencastingStream::failed, this, [this](const QString &error) {
qCWarning(XdgDesktopPortalKdeScreenCast) << "ScreenCast session failed" << error;
streamClosed();
});
}
}
void ScreenCastSession::streamClosed()
{
ScreencastingStream *stream = qobject_cast<ScreencastingStream *>(sender());
std::remove_if(m_streams.begin(), m_streams.end(), [stream](const WaylandIntegration::Stream &s) {
return s.stream == stream;
});
if (m_streams.isEmpty()) {
close();
}
}
......@@ -75,16 +75,14 @@ public:
{
return m_streams;
}
void setStreams(const WaylandIntegration::Streams &streams)
{
m_streams = streams;
}
void setStreams(const WaylandIntegration::Streams &streams);
private:
bool m_multipleSources;
ScreenCastPortal::CursorModes m_cursorMode;
ScreenCastPortal::SourceType m_types;
ScreenCastPortal::PersistMode m_persistMode = ScreenCastPortal::NoPersist;
void streamClosed();
WaylandIntegration::Streams m_streams;
QVariant m_restoreData;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment