summaryrefslogtreecommitdiff
path: root/kde-plasma/xdg-desktop-portal-kde/files/xdg-desktop-portal-kde-5.24.5-screencast-close-only-streams-of-closing-session.patch
blob: 134f55c900b510ce7e4390ed3abc5a3c807d4feb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
From cd8275c722aa25dd22353121131c914d3ab3b438 Mon Sep 17 00:00:00 2001
From: Aleix Pol <aleixpol@kde.org>
Date: Sat, 28 May 2022 03:36:14 +0200
Subject: [PATCH] screencast: When closing a session, only close the streams
 from that session

---
 src/screencast.cpp         | 11 ++++++++---
 src/session.h              | 12 ++++++++++++
 src/waylandintegration.cpp |  5 +++++
 src/waylandintegration.h   |  1 +
 4 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/screencast.cpp b/src/screencast.cpp
index 5be6210..84cc4bd 100644
--- a/src/screencast.cpp
+++ b/src/screencast.cpp
@@ -68,8 +68,12 @@ uint ScreenCastPortal::CreateSession(const QDBusObjectPath &handle,
         return 2;
     }
 
-    connect(session, &Session::closed, []() {
-        WaylandIntegration::stopAllStreaming();
+    connect(session, &Session::closed, [session] {
+        auto screencastSession = qobject_cast<ScreenCastSession *>(session);
+        const auto streams = screencastSession->streams();
+        for (const WaylandIntegration::Stream &stream : streams) {
+            WaylandIntegration::stopStreaming(stream.nodeId);
+        }
     });
 
     connect(WaylandIntegration::waylandIntegration(), &WaylandIntegration::WaylandIntegration::streamingStopped, session, &Session::close);
@@ -169,7 +173,8 @@ uint ScreenCastPortal::Start(const QDBusObjectPath &handle,
             return 2;
         }
 
-        results.insert(QStringLiteral("streams"), QVariant::fromValue(streams));
+        session->setStreams(streams);
+        results.insert(QStringLiteral("streams"), QVariant::fromValue<WaylandIntegration::Streams>(streams));
 
         if (inhibitionsEnabled()) {
             new NotificationInhibition(app_id, i18nc("Do not disturb mode is enabled because...", "Screen sharing in progress"), session);
diff --git a/src/session.h b/src/session.h
index a42222e..dd05680 100644
--- a/src/session.h
+++ b/src/session.h
@@ -14,6 +14,7 @@
 
 #include "remotedesktop.h"
 #include "screencast.h"
+#include "waylandintegration.h"
 
 class Session : public QDBusVirtualObject
 {
@@ -62,10 +63,21 @@ public:
         return SessionType::ScreenCast;
     }
 
+    WaylandIntegration::Streams streams() const
+    {
+        return m_streams;
+    }
+    void setStreams(const WaylandIntegration::Streams &streams)
+    {
+        m_streams = streams;
+    }
+
 private:
     bool m_multipleSources;
     ScreenCastPortal::CursorModes m_cursorMode;
     ScreenCastPortal::SourceType m_types;
+
+    WaylandIntegration::Streams m_streams;
 };
 
 class RemoteDesktopSession : public ScreenCastSession
diff --git a/src/waylandintegration.cpp b/src/waylandintegration.cpp
index 9f5a177..e05f73a 100644
--- a/src/waylandintegration.cpp
+++ b/src/waylandintegration.cpp
@@ -89,6 +89,11 @@ void WaylandIntegration::stopAllStreaming()
     globalWaylandIntegration->stopAllStreaming();
 }
 
+void WaylandIntegration::stopStreaming(uint node)
+{
+    globalWaylandIntegration->stopStreaming(node);
+}
+
 void WaylandIntegration::requestPointerButtonPress(quint32 linuxButton)
 {
     globalWaylandIntegration->requestPointerButtonPress(linuxButton);
diff --git a/src/waylandintegration.h b/src/waylandintegration.h
index b8e6a00..784ee12 100644
--- a/src/waylandintegration.h
+++ b/src/waylandintegration.h
@@ -131,6 +131,7 @@ void startStreamingInput();
 Stream startStreamingOutput(quint32 outputName, Screencasting::CursorMode mode);
 Stream startStreamingWindow(const QMap<int, QVariant> &win);
 void stopAllStreaming();
+void stopStreaming(uint node);
 
 void requestPointerButtonPress(quint32 linuxButton);
 void requestPointerButtonRelease(quint32 linuxButton);
-- 
GitLab