mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 08:30:42 -05:00
native: Replace 'headless' property with 'mode' property
There will be another mode added later, 'test'; prepare for this by changing the existing "mode" boolean ('headless') to a mode, which is either 'default' or 'headless'. Checking the is_headless variable is changed to using the function is_headless(), except for one place, being VT switching, which in preparation is only allowed on the 'default' mode. Other places where it makes sense, the conditions are changed to switch statements. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
This commit is contained in:
parent
a2382f3251
commit
124a1582e1
@ -39,4 +39,10 @@ typedef enum _MetaSeatNativeFlag
|
|||||||
META_SEAT_NATIVE_FLAG_NO_LIBINPUT = 1 << 0,
|
META_SEAT_NATIVE_FLAG_NO_LIBINPUT = 1 << 0,
|
||||||
} MetaSeatNativeFlag;
|
} MetaSeatNativeFlag;
|
||||||
|
|
||||||
|
typedef enum _MetaBackendNativeMode
|
||||||
|
{
|
||||||
|
META_BACKEND_NATIVE_MODE_DEFAULT = 0,
|
||||||
|
META_BACKEND_NATIVE_MODE_HEADLESS,
|
||||||
|
} MetaBackendNativeMode;
|
||||||
|
|
||||||
#endif /* META_BACKEND_NATIVE_TYPES_H */
|
#endif /* META_BACKEND_NATIVE_TYPES_H */
|
||||||
|
@ -66,11 +66,13 @@
|
|||||||
#include "backends/meta-screen-cast.h"
|
#include "backends/meta-screen-cast.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "meta-private-enum-types.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
|
||||||
PROP_HEADLESS,
|
PROP_MODE,
|
||||||
|
|
||||||
N_PROPS
|
N_PROPS
|
||||||
};
|
};
|
||||||
@ -86,7 +88,7 @@ struct _MetaBackendNative
|
|||||||
MetaUdev *udev;
|
MetaUdev *udev;
|
||||||
MetaKms *kms;
|
MetaKms *kms;
|
||||||
|
|
||||||
gboolean is_headless;
|
MetaBackendNativeMode mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
static GInitableIface *initable_parent_iface;
|
static GInitableIface *initable_parent_iface;
|
||||||
@ -254,10 +256,12 @@ meta_backend_native_create_monitor_manager (MetaBackend *backend,
|
|||||||
{
|
{
|
||||||
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
||||||
MetaMonitorManager *manager;
|
MetaMonitorManager *manager;
|
||||||
|
gboolean needs_outputs;
|
||||||
|
|
||||||
|
needs_outputs = !(backend_native->mode & META_BACKEND_NATIVE_MODE_HEADLESS);
|
||||||
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,
|
"needs-outputs", needs_outputs,
|
||||||
NULL);
|
NULL);
|
||||||
if (!manager)
|
if (!manager)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -372,16 +376,22 @@ meta_backend_native_lock_layout_group (MetaBackend *backend,
|
|||||||
const char *
|
const char *
|
||||||
meta_backend_native_get_seat_id (MetaBackendNative *backend_native)
|
meta_backend_native_get_seat_id (MetaBackendNative *backend_native)
|
||||||
{
|
{
|
||||||
if (backend_native->is_headless)
|
switch (backend_native->mode)
|
||||||
return "seat0";
|
{
|
||||||
else
|
case META_BACKEND_NATIVE_MODE_DEFAULT:
|
||||||
return meta_launcher_get_seat_id (backend_native->launcher);
|
return meta_launcher_get_seat_id (backend_native->launcher);
|
||||||
|
case META_BACKEND_NATIVE_MODE_HEADLESS:
|
||||||
|
return "seat0";
|
||||||
|
}
|
||||||
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_backend_native_is_headless (MetaBackend *backend)
|
meta_backend_native_is_headless (MetaBackend *backend)
|
||||||
{
|
{
|
||||||
return META_BACKEND_NATIVE (backend)->is_headless;
|
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
||||||
|
|
||||||
|
return backend_native->mode == META_BACKEND_NATIVE_MODE_HEADLESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -537,7 +547,7 @@ init_gpus (MetaBackendNative *native,
|
|||||||
|
|
||||||
g_list_free_full (devices, g_object_unref);
|
g_list_free_full (devices, g_object_unref);
|
||||||
|
|
||||||
if (!native->is_headless &&
|
if (!meta_backend_is_headless (backend) &&
|
||||||
g_list_length (meta_backend_get_gpus (backend)) == 0)
|
g_list_length (meta_backend_get_gpus (backend)) == 0)
|
||||||
{
|
{
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
||||||
@ -558,6 +568,7 @@ meta_backend_native_initable_init (GInitable *initable,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
MetaBackendNative *native = META_BACKEND_NATIVE (initable);
|
MetaBackendNative *native = META_BACKEND_NATIVE (initable);
|
||||||
|
MetaBackend *backend = META_BACKEND (native);
|
||||||
MetaKmsFlags kms_flags;
|
MetaKmsFlags kms_flags;
|
||||||
|
|
||||||
if (!meta_is_stage_views_enabled ())
|
if (!meta_is_stage_views_enabled ())
|
||||||
@ -567,7 +578,7 @@ meta_backend_native_initable_init (GInitable *initable,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!native->is_headless)
|
if (!meta_backend_is_headless (backend))
|
||||||
{
|
{
|
||||||
native->launcher = meta_launcher_new (error);
|
native->launcher = meta_launcher_new (error);
|
||||||
if (!native->launcher)
|
if (!native->launcher)
|
||||||
@ -578,7 +589,7 @@ meta_backend_native_initable_init (GInitable *initable,
|
|||||||
native->udev = meta_udev_new (native);
|
native->udev = meta_udev_new (native);
|
||||||
|
|
||||||
kms_flags = META_KMS_FLAG_NONE;
|
kms_flags = META_KMS_FLAG_NONE;
|
||||||
if (native->is_headless)
|
if (meta_backend_is_headless (backend))
|
||||||
kms_flags |= META_KMS_FLAG_NO_MODE_SETTING;
|
kms_flags |= META_KMS_FLAG_NO_MODE_SETTING;
|
||||||
|
|
||||||
native->kms = meta_kms_new (META_BACKEND (native), kms_flags, error);
|
native->kms = meta_kms_new (META_BACKEND (native), kms_flags, error);
|
||||||
@ -601,8 +612,8 @@ meta_backend_native_set_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_HEADLESS:
|
case PROP_MODE:
|
||||||
backend_native->is_headless = g_value_get_boolean (value);
|
backend_native->mode = g_value_get_enum (value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@ -649,14 +660,15 @@ meta_backend_native_class_init (MetaBackendNativeClass *klass)
|
|||||||
|
|
||||||
backend_class->is_headless = meta_backend_native_is_headless;
|
backend_class->is_headless = meta_backend_native_is_headless;
|
||||||
|
|
||||||
obj_props[PROP_HEADLESS] =
|
obj_props[PROP_MODE] =
|
||||||
g_param_spec_boolean ("headless",
|
g_param_spec_enum ("mode",
|
||||||
"headless",
|
"mode",
|
||||||
"Headless",
|
"mode",
|
||||||
FALSE,
|
META_TYPE_BACKEND_NATIVE_MODE,
|
||||||
G_PARAM_WRITABLE |
|
META_BACKEND_NATIVE_MODE_DEFAULT,
|
||||||
G_PARAM_CONSTRUCT_ONLY |
|
G_PARAM_WRITABLE |
|
||||||
G_PARAM_STATIC_STRINGS);
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_STATIC_STRINGS);
|
||||||
g_object_class_install_properties (object_class, N_PROPS, obj_props);
|
g_object_class_install_properties (object_class, N_PROPS, obj_props);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -696,14 +708,18 @@ meta_activate_vt (int vt, GError **error)
|
|||||||
MetaBackendNative *native = META_BACKEND_NATIVE (backend);
|
MetaBackendNative *native = META_BACKEND_NATIVE (backend);
|
||||||
MetaLauncher *launcher = meta_backend_native_get_launcher (native);
|
MetaLauncher *launcher = meta_backend_native_get_launcher (native);
|
||||||
|
|
||||||
if (native->is_headless)
|
switch (native->mode)
|
||||||
{
|
{
|
||||||
|
case META_BACKEND_NATIVE_MODE_DEFAULT:
|
||||||
|
return meta_launcher_activate_vt (launcher, vt, error);
|
||||||
|
case META_BACKEND_NATIVE_MODE_HEADLESS:
|
||||||
|
case META_BACKEND_NATIVE_MODE_TEST:
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
"Can't switch VT while headless");
|
"Can't switch VT while headless");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return meta_launcher_activate_vt (launcher, vt, error);
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -438,7 +438,7 @@ create_headless_backend (MetaContext *context,
|
|||||||
return g_initable_new (META_TYPE_BACKEND_NATIVE,
|
return g_initable_new (META_TYPE_BACKEND_NATIVE,
|
||||||
NULL, error,
|
NULL, error,
|
||||||
"context", context,
|
"context", context,
|
||||||
"headless", TRUE,
|
"mode", META_BACKEND_NATIVE_MODE_HEADLESS,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ create_headless_backend (MetaContext *context,
|
|||||||
return g_initable_new (META_TYPE_BACKEND_NATIVE,
|
return g_initable_new (META_TYPE_BACKEND_NATIVE,
|
||||||
NULL, error,
|
NULL, error,
|
||||||
"context", context,
|
"context", context,
|
||||||
"headless", TRUE,
|
"mode", META_BACKEND_NATIVE_MODE_HEADLESS,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_NATIVE_BACKEND */
|
#endif /* HAVE_NATIVE_BACKEND */
|
||||||
|
Loading…
Reference in New Issue
Block a user