[mutter] screen-cast: Clean up sessions on 'prepare-shutdown'



commit 2a81c6d3930434512757a9138615c1b0d3266f84
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Wed Jun 9 18:13:53 2021 +0200

    screen-cast: Clean up sessions on 'prepare-shutdown'
    
    However, leave the remote desktop screen cast sessions to the remote
    desktop manager to close.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1891>

 src/backends/meta-screen-cast-session.c |  6 ++++++
 src/backends/meta-screen-cast-session.h |  2 ++
 src/backends/meta-screen-cast.c         | 19 ++++++++++++++++---
 3 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/src/backends/meta-screen-cast-session.c b/src/backends/meta-screen-cast-session.c
index 3925738d47..60fffdea5e 100644
--- a/src/backends/meta-screen-cast-session.c
+++ b/src/backends/meta-screen-cast-session.c
@@ -194,6 +194,12 @@ meta_screen_cast_session_get_peer_name (MetaScreenCastSession *session)
   return session->peer_name;
 }
 
+MetaScreenCastSessionType
+meta_screen_cast_session_get_session_type (MetaScreenCastSession *session)
+{
+  return session->session_type;
+}
+
 static gboolean
 check_permission (MetaScreenCastSession *session,
                   GDBusMethodInvocation *invocation)
diff --git a/src/backends/meta-screen-cast-session.h b/src/backends/meta-screen-cast-session.h
index 3bab3486b7..46bde5eb9b 100644
--- a/src/backends/meta-screen-cast-session.h
+++ b/src/backends/meta-screen-cast-session.h
@@ -49,6 +49,8 @@ char * meta_screen_cast_session_get_object_path (MetaScreenCastSession *session)
 
 char * meta_screen_cast_session_get_peer_name (MetaScreenCastSession *session);
 
+MetaScreenCastSessionType meta_screen_cast_session_get_session_type (MetaScreenCastSession *session);
+
 MetaScreenCastSession * meta_screen_cast_session_new (MetaScreenCast             *screen_cast,
                                                       MetaScreenCastSessionType   session_type,
                                                       const char                 *peer_name,
diff --git a/src/backends/meta-screen-cast.c b/src/backends/meta-screen-cast.c
index 13809d853c..6162b8d276 100644
--- a/src/backends/meta-screen-cast.c
+++ b/src/backends/meta-screen-cast.c
@@ -323,14 +323,23 @@ meta_screen_cast_finalize (GObject *object)
   if (screen_cast->dbus_name_id)
     g_bus_unown_name (screen_cast->dbus_name_id);
 
+  g_assert (!screen_cast->sessions);
+
+  G_OBJECT_CLASS (meta_screen_cast_parent_class)->finalize (object);
+}
+
+static void
+on_prepare_shutdown (MetaBackend    *backend,
+                     MetaScreenCast *screen_cast)
+{
   while (screen_cast->sessions)
     {
       MetaScreenCastSession *session = screen_cast->sessions->data;
 
-      meta_screen_cast_session_close (session);
+      if (meta_screen_cast_session_get_session_type (session) !=
+          META_SCREEN_CAST_SESSION_TYPE_REMOTE_DESKTOP)
+        meta_screen_cast_session_close (session);
     }
-
-  G_OBJECT_CLASS (meta_screen_cast_parent_class)->finalize (object);
 }
 
 MetaScreenCast *
@@ -343,6 +352,10 @@ meta_screen_cast_new (MetaBackend            *backend,
   screen_cast->backend = backend;
   screen_cast->session_watcher = session_watcher;
 
+  g_signal_connect (backend, "prepare-shutdown",
+                    G_CALLBACK (on_prepare_shutdown),
+                    screen_cast);
+
   return screen_cast;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]