From b33d02e04877bfeeaa43671d3b1b48e0680fc12d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 22 Aug 2022 18:45:46 +1000 Subject: [PATCH] session: emit the Closed signal when we're closing on our own account If a RemoteDesktop/ScreenCast session is closed by mutter, send out the Closed signal on our impl.portal.Session to notify the xdg-desktop-portal that we're done. Related: https://github.com/flatpak/xdg-desktop-portal/issues/508 --- src/remotedesktop.c | 2 +- src/screencast.c | 2 +- src/session.c | 11 +++++++++-- src/session.h | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/remotedesktop.c b/src/remotedesktop.c index 46d1dcc..0298f68 100644 --- a/src/remotedesktop.c +++ b/src/remotedesktop.c @@ -266,7 +266,7 @@ static void on_mutter_session_closed (OrgGnomeMutterRemoteDesktopSession *mutter_session_proxy, RemoteDesktopSession *remote_desktop_session) { - session_close ((Session *)remote_desktop_session); + session_close ((Session *)remote_desktop_session, TRUE); } static RemoteDesktopSession * diff --git a/src/screencast.c b/src/screencast.c index 15f6a80..0a15033 100644 --- a/src/screencast.c +++ b/src/screencast.c @@ -243,7 +243,7 @@ static void on_gnome_screen_cast_session_closed (GnomeScreenCastSession *gnome_screen_cast_session, ScreenCastSession *screen_cast_session) { - session_close ((Session *)screen_cast_session); + session_close ((Session *)screen_cast_session, TRUE); } static gboolean diff --git a/src/session.c b/src/session.c index 5ebe13f..b428ef8 100644 --- a/src/session.c +++ b/src/session.c @@ -73,8 +73,15 @@ session_unexport (Session *session) } void -session_close (Session *session) +session_close (Session *session, gboolean notify) { + if (notify) + { + GVariantBuilder details_builder; + g_variant_builder_init (&details_builder, G_VARIANT_TYPE_VARDICT); + g_signal_emit_by_name (session, "closed", g_variant_builder_end (&details_builder)); + } + if (session->exported) session_unexport (session); @@ -92,7 +99,7 @@ handle_close (XdpImplSession *object, Session *session = (Session *)object; if (!session->closed) - session_close (session); + session_close (session, FALSE); xdp_impl_session_complete_close (object, invocation); diff --git a/src/session.h b/src/session.h index 4a1173a..7594bd8 100644 --- a/src/session.h +++ b/src/session.h @@ -47,7 +47,7 @@ Session *lookup_session (const char *id); Session *session_new (const char *id); -void session_close (Session *session); +void session_close (Session *session, gboolean notify); gboolean session_export (Session *session, GDBusConnection *connection,