mirror of
https://github.com/brl/mutter.git
synced 2024-12-26 04:42:14 +00:00
launcher: Pass fallback session/seat ID when in test mode
When we test, we might not have a systemd session to rely on, and this may cause some API we depend on to get various session related data to not work properly. Avoid this issue by passing fallback values for these when we're running in test mode. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
This commit is contained in:
parent
8372af9cd7
commit
1cc786ffd3
@ -605,7 +605,23 @@ meta_backend_native_initable_init (GInitable *initable,
|
||||
|
||||
if (!meta_backend_is_headless (backend))
|
||||
{
|
||||
native->launcher = meta_launcher_new (error);
|
||||
const char *session_id = NULL;
|
||||
const char *seat_id = NULL;
|
||||
|
||||
switch (native->mode)
|
||||
{
|
||||
case META_BACKEND_NATIVE_MODE_DEFAULT:
|
||||
break;
|
||||
case META_BACKEND_NATIVE_MODE_HEADLESS:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
case META_BACKEND_NATIVE_MODE_TEST:
|
||||
session_id = "dummy";
|
||||
seat_id = "seat0";
|
||||
break;
|
||||
}
|
||||
|
||||
native->launcher = meta_launcher_new (session_id, seat_id, error);
|
||||
if (!native->launcher)
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -221,8 +221,9 @@ find_systemd_session (gchar **session_id,
|
||||
}
|
||||
|
||||
static MetaDbusLogin1Session *
|
||||
get_session_proxy (GCancellable *cancellable,
|
||||
GError **error)
|
||||
get_session_proxy (const char *fallback_session_id,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autofree char *proxy_path = NULL;
|
||||
g_autofree char *session_id = NULL;
|
||||
@ -232,10 +233,21 @@ get_session_proxy (GCancellable *cancellable,
|
||||
|
||||
if (!find_systemd_session (&session_id, &local_error))
|
||||
{
|
||||
g_propagate_prefixed_error (error,
|
||||
g_steal_pointer (&local_error),
|
||||
"Could not get session ID: ");
|
||||
return NULL;
|
||||
if (fallback_session_id)
|
||||
{
|
||||
meta_topic (META_DEBUG_BACKEND,
|
||||
"Failed to get seat ID: %s, using fallback (%s)",
|
||||
local_error->message, fallback_session_id);
|
||||
g_clear_error (&local_error);
|
||||
session_id = g_strdup (fallback_session_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_propagate_prefixed_error (error,
|
||||
g_steal_pointer (&local_error),
|
||||
"Could not get session ID: ");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
proxy_path = get_escaped_dbus_path ("/org/freedesktop/login1/session", session_id);
|
||||
@ -340,15 +352,18 @@ meta_launcher_get_session_proxy (MetaLauncher *launcher)
|
||||
}
|
||||
|
||||
MetaLauncher *
|
||||
meta_launcher_new (GError **error)
|
||||
meta_launcher_new (const char *fallback_session_id,
|
||||
const char *fallback_seat_id,
|
||||
GError **error)
|
||||
{
|
||||
MetaLauncher *self = NULL;
|
||||
g_autoptr (MetaDbusLogin1Session) session_proxy = NULL;
|
||||
g_autoptr (MetaDbusLogin1Seat) seat_proxy = NULL;
|
||||
g_autoptr (GError) local_error = NULL;
|
||||
g_autofree char *seat_id = NULL;
|
||||
gboolean have_control = FALSE;
|
||||
|
||||
session_proxy = get_session_proxy (NULL, error);
|
||||
session_proxy = get_session_proxy (fallback_session_id, NULL, error);
|
||||
if (!session_proxy)
|
||||
goto fail;
|
||||
|
||||
@ -363,9 +378,23 @@ meta_launcher_new (GError **error)
|
||||
|
||||
have_control = TRUE;
|
||||
|
||||
seat_id = get_seat_id (error);
|
||||
seat_id = get_seat_id (&local_error);
|
||||
if (!seat_id)
|
||||
goto fail;
|
||||
{
|
||||
if (fallback_seat_id)
|
||||
{
|
||||
meta_topic (META_DEBUG_BACKEND,
|
||||
"Failed to get seat ID: %s, using fallback (%s)",
|
||||
local_error->message, fallback_seat_id);
|
||||
g_clear_error (&local_error);
|
||||
seat_id = g_strdup (fallback_seat_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_propagate_error (error, local_error);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
seat_proxy = get_seat_proxy (seat_id, NULL, error);
|
||||
if (!seat_proxy)
|
||||
|
@ -25,7 +25,9 @@
|
||||
typedef struct _MetaLauncher MetaLauncher;
|
||||
typedef struct _MetaDbusLogin1Session MetaDbusLogin1Session;
|
||||
|
||||
MetaLauncher *meta_launcher_new (GError **error);
|
||||
MetaLauncher *meta_launcher_new (const char *session_id,
|
||||
const char *custom_seat_id,
|
||||
GError **error);
|
||||
void meta_launcher_free (MetaLauncher *self);
|
||||
|
||||
gboolean meta_launcher_activate_vt (MetaLauncher *self,
|
||||
|
Loading…
Reference in New Issue
Block a user