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>
This commit is contained in:
Jonas Ådahl 2021-06-09 18:13:53 +02:00 committed by Marge Bot
parent 97c6a68b0d
commit 2a81c6d393
3 changed files with 24 additions and 3 deletions

View File

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

View File

@ -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,

View File

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