From 1e2ef9023dcac27a433300fd876d5c37c9353bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 19 Jan 2021 15:03:17 +0100 Subject: [PATCH] backend/native: Hook up 'headless' mode to input and KMS subsystems With this commit, it's possible to run mutter without being DRM master. It's not yet possible to add virtual monitors, but one can for example already add virtual input devices. This currently doesn't try to hook up to any logind session, thus will not have a real seat assigned. Currently it's hard coded to "seat0". Part-of: --- src/backends/native/meta-backend-native.c | 30 ++++++++++++++----- .../native/meta-clutter-backend-native.c | 7 +++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c index eb43a54ec..65000cb52 100644 --- a/src/backends/native/meta-backend-native.c +++ b/src/backends/native/meta-backend-native.c @@ -332,7 +332,10 @@ meta_backend_native_lock_layout_group (MetaBackend *backend, const char * meta_backend_native_get_seat_id (MetaBackendNative *backend_native) { - return meta_launcher_get_seat_id (backend_native->launcher); + if (backend_native->is_headless) + return "seat0"; + else + return meta_launcher_get_seat_id (backend_native->launcher); } gboolean @@ -513,6 +516,7 @@ meta_backend_native_initable_init (GInitable *initable, GError **error) { MetaBackendNative *native = META_BACKEND_NATIVE (initable); + MetaKmsFlags kms_flags; if (!meta_is_stage_views_enabled ()) { @@ -521,9 +525,12 @@ meta_backend_native_initable_init (GInitable *initable, return FALSE; } - native->launcher = meta_launcher_new (error); - if (!native->launcher) - return FALSE; + if (!native->is_headless) + { + native->launcher = meta_launcher_new (error); + if (!native->launcher) + return FALSE; + } #ifdef HAVE_WAYLAND meta_backend_init_wayland_display (META_BACKEND (native)); @@ -531,9 +538,11 @@ meta_backend_native_initable_init (GInitable *initable, native->udev = meta_udev_new (native); - native->kms = meta_kms_new (META_BACKEND (native), - META_KMS_FLAG_NONE, - error); + kms_flags = META_KMS_FLAG_NONE; + if (native->is_headless) + kms_flags |= META_KMS_FLAG_NO_MODE_SETTING; + + native->kms = meta_kms_new (META_BACKEND (native), kms_flags, error); if (!native->kms) return FALSE; @@ -639,6 +648,13 @@ meta_activate_vt (int vt, GError **error) MetaBackendNative *native = META_BACKEND_NATIVE (backend); MetaLauncher *launcher = meta_backend_native_get_launcher (native); + if (native->is_headless) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "Can't switch VT while headless"); + return FALSE; + } + return meta_launcher_activate_vt (launcher, vt, error); } diff --git a/src/backends/native/meta-clutter-backend-native.c b/src/backends/native/meta-clutter-backend-native.c index 798f670c1..46156d898 100644 --- a/src/backends/native/meta-clutter-backend-native.c +++ b/src/backends/native/meta-clutter-backend-native.c @@ -106,12 +106,19 @@ meta_clutter_backend_native_init_events (ClutterBackend *clutter_backend) MetaBackend *backend = meta_get_backend (); MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend); const char *seat_id; + MetaSeatNativeFlag flags; seat_id = meta_backend_native_get_seat_id (backend_native); + if (meta_backend_native_is_headless (backend_native)) + flags = META_SEAT_NATIVE_FLAG_NO_LIBINPUT; + else + flags = META_SEAT_NATIVE_FLAG_NONE; + clutter_backend_native->main_seat = g_object_new (META_TYPE_SEAT_NATIVE, "backend", clutter_backend, "seat-id", seat_id, + "flags", flags, NULL); }