dbus-session: Rename client_vanished() to close()

This means the MetaDbusSession interface takes a more active role
instead of being something that more or less sends signals to the
interface implementor. This will allow better control when using
MetaDbusSession to manage these sessions, instead of their non-abstract
variants.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2713>
This commit is contained in:
Jonas Ådahl 2022-03-11 00:35:14 +01:00 committed by Marge Bot
parent abdd8c54f3
commit 7874bea068
8 changed files with 34 additions and 46 deletions

View File

@ -57,12 +57,6 @@ typedef struct _MetaDbusSessionClient
GList *sessions;
} MetaDbusSessionClient;
static void
meta_dbus_session_client_vanished (MetaDbusSession *session)
{
META_DBUS_SESSION_GET_IFACE (session)->client_vanished (session);
}
static void
meta_dbus_session_client_destroy (MetaDbusSessionClient *client)
{
@ -77,11 +71,7 @@ meta_dbus_session_client_destroy (MetaDbusSessionClient *client)
session = l->data;
/*
* This will invoke on_session_closed which removes the session from the
* list.
*/
meta_dbus_session_client_vanished (session);
meta_dbus_session_close (session);
}
if (client->name_watcher_id)
@ -235,3 +225,9 @@ meta_dbus_session_watcher_class_init (MetaDbusSessionWatcherClass *klass)
object_class->finalize = meta_dbus_session_watcher_finalize;
}
void
meta_dbus_session_close (MetaDbusSession *session)
{
META_DBUS_SESSION_GET_IFACE (session)->close (session);
}

View File

@ -34,7 +34,7 @@ struct _MetaDbusSessionInterface
{
GTypeInterface parent_iface;
void (* client_vanished) (MetaDbusSession *session);
void (* close) (MetaDbusSession *session);
};
#define META_TYPE_DBUS_SESSION_WATCHER (meta_dbus_session_watcher_get_type ())
@ -49,4 +49,6 @@ void meta_dbus_session_watcher_watch_session (MetaDbusSessionWatcher *session_wa
void meta_dbus_session_notify_closed (MetaDbusSession *session);
void meta_dbus_session_close (MetaDbusSession *session);
#endif /* META_DBUS_SESSION_WATCHER_H */

View File

@ -207,9 +207,11 @@ meta_remote_desktop_session_start (MetaRemoteDesktopSession *session,
return TRUE;
}
void
meta_remote_desktop_session_close (MetaRemoteDesktopSession *session)
static void
meta_remote_desktop_session_close (MetaDbusSession *dbus_session)
{
MetaRemoteDesktopSession *session =
META_REMOTE_DESKTOP_SESSION (dbus_session);
MetaDBusRemoteDesktopSession *skeleton =
META_DBUS_REMOTE_DESKTOP_SESSION (session);
@ -217,9 +219,12 @@ meta_remote_desktop_session_close (MetaRemoteDesktopSession *session)
if (session->screen_cast_session)
{
MetaDbusSession *screen_cast_session =
META_DBUS_SESSION (session->screen_cast_session);
g_clear_signal_handler (&session->screen_cast_session_closed_handler_id,
session->screen_cast_session);
meta_screen_cast_session_close (session->screen_cast_session);
meta_dbus_session_close (screen_cast_session);
session->screen_cast_session = NULL;
}
@ -259,7 +264,7 @@ on_screen_cast_session_closed (MetaScreenCastSession *screen_cast_session,
MetaRemoteDesktopSession *session)
{
session->screen_cast_session = NULL;
meta_remote_desktop_session_close (session);
meta_dbus_session_close (META_DBUS_SESSION (session));
}
gboolean
@ -384,7 +389,7 @@ handle_start (MetaDBusRemoteDesktopSession *skeleton,
error->message);
g_error_free (error);
meta_remote_desktop_session_close (session);
meta_dbus_session_close (META_DBUS_SESSION (session));
return TRUE;
}
@ -416,7 +421,7 @@ handle_stop (MetaDBusRemoteDesktopSession *skeleton,
return TRUE;
}
meta_remote_desktop_session_close (session);
meta_dbus_session_close (META_DBUS_SESSION (session));
meta_dbus_remote_desktop_session_complete_stop (skeleton, invocation);
@ -1675,16 +1680,10 @@ meta_remote_desktop_session_init_iface (MetaDBusRemoteDesktopSessionIface *iface
iface->handle_selection_read = handle_selection_read;
}
static void
meta_remote_desktop_session_client_vanished (MetaDbusSession *dbus_session)
{
meta_remote_desktop_session_close (META_REMOTE_DESKTOP_SESSION (dbus_session));
}
static void
meta_dbus_session_init_iface (MetaDbusSessionInterface *iface)
{
iface->client_vanished = meta_remote_desktop_session_client_vanished;
iface->close = meta_remote_desktop_session_close;
}
static void
@ -1759,7 +1758,7 @@ meta_remote_desktop_session_handle_stop (MetaRemoteAccessHandle *handle)
if (!session)
return;
meta_remote_desktop_session_close (session);
meta_dbus_session_close (META_DBUS_SESSION (session));
}
static void

View File

@ -51,8 +51,6 @@ void meta_remote_desktop_session_request_transfer (MetaRemoteDesktopSession *se
const char *mime_type,
GTask *task);
void meta_remote_desktop_session_close (MetaRemoteDesktopSession *session);
MetaRemoteDesktopSession * meta_remote_desktop_session_new (MetaRemoteDesktop *remote_desktop,
const char *peer_name,
GError **error);

View File

@ -88,7 +88,7 @@ meta_remote_desktop_inhibit (MetaRemoteDesktop *remote_desktop)
MetaRemoteDesktopSession *session = value;
g_hash_table_iter_steal (&iter);
meta_remote_desktop_session_close (session);
meta_dbus_session_close (META_DBUS_SESSION (session));
}
}
}
@ -262,7 +262,7 @@ on_prepare_shutdown (MetaBackend *backend,
MetaRemoteDesktopSession *session = value;
g_hash_table_iter_steal (&iter);
meta_remote_desktop_session_close (session);
meta_dbus_session_close (META_DBUS_SESSION (session));
}
}

View File

@ -130,9 +130,10 @@ meta_screen_cast_session_is_active (MetaScreenCastSession *session)
return session->is_active;
}
void
meta_screen_cast_session_close (MetaScreenCastSession *session)
static void
meta_screen_cast_session_close (MetaDbusSession *dbus_session)
{
MetaScreenCastSession *session = META_SCREEN_CAST_SESSION (dbus_session);
MetaDBusScreenCastSession *skeleton = META_DBUS_SCREEN_CAST_SESSION (session);
session->is_active = FALSE;
@ -287,7 +288,7 @@ handle_stop (MetaDBusScreenCastSession *skeleton,
return TRUE;
}
meta_screen_cast_session_close (session);
meta_dbus_session_close (META_DBUS_SESSION (session));
meta_dbus_screen_cast_session_complete_stop (skeleton, invocation);
@ -298,7 +299,7 @@ static void
on_stream_closed (MetaScreenCastStream *stream,
MetaScreenCastSession *session)
{
meta_screen_cast_session_close (session);
meta_dbus_session_close (META_DBUS_SESSION (session));
}
static gboolean
@ -710,16 +711,10 @@ meta_screen_cast_session_init_iface (MetaDBusScreenCastSessionIface *iface)
iface->handle_record_virtual = handle_record_virtual;
}
static void
meta_screen_cast_session_client_vanished (MetaDbusSession *dbus_session)
{
meta_screen_cast_session_close (META_SCREEN_CAST_SESSION (dbus_session));
}
static void
meta_dbus_session_init_iface (MetaDbusSessionInterface *iface)
{
iface->client_vanished = meta_screen_cast_session_client_vanished;
iface->close = meta_screen_cast_session_close;
}
MetaScreenCastSession *
@ -822,7 +817,7 @@ meta_screen_cast_session_handle_stop (MetaRemoteAccessHandle *handle)
if (!session)
return;
meta_screen_cast_session_close (session);
meta_dbus_session_close (META_DBUS_SESSION (session));
}
static void

View File

@ -61,8 +61,6 @@ gboolean meta_screen_cast_session_start (MetaScreenCastSession *session,
gboolean meta_screen_cast_session_is_active (MetaScreenCastSession *session);
void meta_screen_cast_session_close (MetaScreenCastSession *session);
MetaScreenCastStream * meta_screen_cast_session_get_stream (MetaScreenCastSession *session,
const char *path);

View File

@ -68,7 +68,7 @@ meta_screen_cast_inhibit (MetaScreenCast *screen_cast)
{
MetaScreenCastSession *session = screen_cast->sessions->data;
meta_screen_cast_session_close (session);
meta_dbus_session_close (META_DBUS_SESSION (session));
}
}
}
@ -338,7 +338,7 @@ on_prepare_shutdown (MetaBackend *backend,
if (meta_screen_cast_session_get_session_type (session) !=
META_SCREEN_CAST_SESSION_TYPE_REMOTE_DESKTOP)
meta_screen_cast_session_close (session);
meta_dbus_session_close (META_DBUS_SESSION (session));
}
}