1
0
Fork 0

monitor-manager/native: Allow starting without outputs when headless

This will allow starting, then adding virtual outputs when needed e.g.
via the screen cast API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
This commit is contained in:
Jonas Ådahl 2021-01-18 22:34:04 +01:00 committed by Marge Bot
parent 34b0f9c124
commit 59a10cd188
2 changed files with 49 additions and 1 deletions

View file

@ -212,10 +212,12 @@ static MetaMonitorManager *
meta_backend_native_create_monitor_manager (MetaBackend *backend, meta_backend_native_create_monitor_manager (MetaBackend *backend,
GError **error) GError **error)
{ {
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
MetaMonitorManager *manager; MetaMonitorManager *manager;
manager = g_initable_new (META_TYPE_MONITOR_MANAGER_NATIVE, NULL, error, manager = g_initable_new (META_TYPE_MONITOR_MANAGER_NATIVE, NULL, error,
"backend", backend, "backend", backend,
"needs-outputs", !backend_native->is_headless,
NULL); NULL);
if (!manager) if (!manager)
return NULL; return NULL;

View file

@ -63,6 +63,17 @@
#include "meta/main.h" #include "meta/main.h"
#include "meta/meta-x11-errors.h" #include "meta/meta-x11-errors.h"
enum
{
PROP_0,
PROP_NEED_OUTPUTS,
N_PROPS
};
static GParamSpec *obj_props[N_PROPS];
struct _MetaMonitorManagerNative struct _MetaMonitorManagerNative
{ {
MetaMonitorManager parent_instance; MetaMonitorManager parent_instance;
@ -70,6 +81,8 @@ struct _MetaMonitorManagerNative
gulong kms_resources_changed_handler_id; gulong kms_resources_changed_handler_id;
GHashTable *crtc_gamma_cache; GHashTable *crtc_gamma_cache;
gboolean needs_outputs;
}; };
struct _MetaMonitorManagerNativeClass struct _MetaMonitorManagerNativeClass
@ -588,6 +601,26 @@ meta_monitor_manager_native_get_default_layout_mode (MetaMonitorManager *manager
return META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL; return META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL;
} }
static void
meta_monitor_manager_native_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
MetaMonitorManagerNative *manager_native =
META_MONITOR_MANAGER_NATIVE (object);
switch (prop_id)
{
case PROP_NEED_OUTPUTS:
manager_native->needs_outputs = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void static void
meta_monitor_manager_native_dispose (GObject *object) meta_monitor_manager_native_dispose (GObject *object)
{ {
@ -625,7 +658,8 @@ meta_monitor_manager_native_initable_init (GInitable *initable,
break; break;
} }
} }
if (!can_have_outputs)
if (manager_native->needs_outputs && !can_have_outputs)
{ {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"No GPUs with outputs found"); "No GPUs with outputs found");
@ -649,6 +683,7 @@ initable_iface_init (GInitableIface *initable_iface)
static void static void
meta_monitor_manager_native_init (MetaMonitorManagerNative *manager_native) meta_monitor_manager_native_init (MetaMonitorManagerNative *manager_native)
{ {
manager_native->needs_outputs = TRUE;
} }
static void static void
@ -657,6 +692,7 @@ meta_monitor_manager_native_class_init (MetaMonitorManagerNativeClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
MetaMonitorManagerClass *manager_class = META_MONITOR_MANAGER_CLASS (klass); MetaMonitorManagerClass *manager_class = META_MONITOR_MANAGER_CLASS (klass);
object_class->set_property = meta_monitor_manager_native_set_property;
object_class->dispose = meta_monitor_manager_native_dispose; object_class->dispose = meta_monitor_manager_native_dispose;
manager_class->read_edid = manager_class->read_edid =
@ -685,4 +721,14 @@ meta_monitor_manager_native_class_init (MetaMonitorManagerNativeClass *klass)
meta_monitor_manager_native_get_max_screen_size; meta_monitor_manager_native_get_max_screen_size;
manager_class->get_default_layout_mode = manager_class->get_default_layout_mode =
meta_monitor_manager_native_get_default_layout_mode; meta_monitor_manager_native_get_default_layout_mode;
obj_props[PROP_NEED_OUTPUTS] =
g_param_spec_boolean ("needs-outputs",
"needs-outputs",
"Whether any outputs are needed for operation",
TRUE,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, obj_props);
} }