backends/native: Set headless mode when no seat_id

This forces not using the seat_proxy. But still allows the use of
session_proxy.

On tests, headless mode is explicitly set and it might not be available a
systemd session. To avoid test failing on this situation skip using
meta_launcher wich uses session_proxy and seat_proxy.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3093>
This commit is contained in:
Joan Torres 2023-06-09 16:19:09 +02:00 committed by Marge Bot
parent f0bb540797
commit adf12504c0
2 changed files with 34 additions and 27 deletions

View File

@ -775,9 +775,6 @@ meta_backend_native_initable_init (GInitable *initable,
MetaBackendNative *native = META_BACKEND_NATIVE (initable);
MetaBackend *backend = META_BACKEND (native);
MetaKmsFlags kms_flags;
if (!meta_backend_is_headless (backend))
{
const char *session_id = NULL;
const char *seat_id = NULL;
@ -786,7 +783,6 @@ meta_backend_native_initable_init (GInitable *initable,
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";
@ -794,11 +790,19 @@ meta_backend_native_initable_init (GInitable *initable,
break;
}
if (native->mode != META_BACKEND_NATIVE_MODE_HEADLESS)
{
native->launcher = meta_launcher_new (backend,
session_id, seat_id,
error);
if (!native->launcher)
return FALSE;
if (!meta_launcher_get_seat_id (native->launcher))
{
native->mode = META_BACKEND_NATIVE_MODE_HEADLESS;
g_message ("No seat assigned, running headlessly");
}
}
native->device_pool = meta_device_pool_new (native);

View File

@ -409,29 +409,30 @@ meta_launcher_new (MetaBackend *backend,
g_clear_error (&local_error);
seat_id = g_strdup (fallback_seat_id);
}
else
{
g_propagate_error (error, local_error);
goto fail;
}
}
if (seat_id)
{
seat_proxy = get_seat_proxy (seat_id, NULL, error);
if (!seat_proxy)
goto fail;
}
self = g_new0 (MetaLauncher, 1);
self->backend = backend;
self->session_proxy = g_object_ref (session_proxy);
self->session_active = TRUE;
if (seat_id)
{
self->seat_proxy = g_object_ref (seat_proxy);
self->seat_id = g_steal_pointer (&seat_id);
self->session_active = TRUE;
}
g_signal_connect (self->session_proxy, "notify::active", G_CALLBACK (on_active_changed), self);
return self;
fail:
fail:
if (have_control)
{
meta_dbus_login1_session_call_release_control_sync (session_proxy,
@ -454,6 +455,8 @@ meta_launcher_activate_vt (MetaLauncher *launcher,
signed char vt,
GError **error)
{
g_assert (launcher->seat_proxy);
return meta_dbus_login1_seat_call_switch_to_sync (launcher->seat_proxy, vt,
NULL, error);
}