context: Add setup phase
During this phase, the backend is created and configured. Currently only configured, but will gain more logic that currently main.c does with various helpers. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
This commit is contained in:
parent
df8074c636
commit
75f9085ab9
@ -36,6 +36,9 @@ struct _MetaContextClass
|
|||||||
|
|
||||||
MetaCompositorType (* get_compositor_type) (MetaContext *context);
|
MetaCompositorType (* get_compositor_type) (MetaContext *context);
|
||||||
|
|
||||||
|
gboolean (* setup) (MetaContext *context,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
MetaBackend * (* create_backend) (MetaContext *context,
|
MetaBackend * (* create_backend) (MetaContext *context,
|
||||||
GError **error);
|
GError **error);
|
||||||
};
|
};
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
|
#include "backends/meta-backend-private.h"
|
||||||
#include "core/util-private.h"
|
#include "core/util-private.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -75,6 +76,41 @@ meta_context_configure (MetaContext *context,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
compositor_type_to_description (MetaCompositorType compositor_type)
|
||||||
|
{
|
||||||
|
switch (compositor_type)
|
||||||
|
{
|
||||||
|
case META_COMPOSITOR_TYPE_WAYLAND:
|
||||||
|
return "Wayland display server";
|
||||||
|
case META_COMPOSITOR_TYPE_X11:
|
||||||
|
return "X11 window and compositing manager";
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
meta_context_real_setup (MetaContext *context,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return !!META_CONTEXT_GET_CLASS (context)->create_backend (context, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_context_setup (MetaContext *context,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
MetaContextPrivate *priv = meta_context_get_instance_private (context);
|
||||||
|
MetaCompositorType compositor_type;
|
||||||
|
|
||||||
|
compositor_type = meta_context_get_compositor_type (context);
|
||||||
|
g_message ("Running %s (using mutter %s) as a %s",
|
||||||
|
priv->name, VERSION,
|
||||||
|
compositor_type_to_description (compositor_type));
|
||||||
|
return META_CONTEXT_GET_CLASS (context)->setup (context, error);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_context_get_property (GObject *object,
|
meta_context_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@ -120,6 +156,13 @@ meta_context_finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
MetaContext *context = META_CONTEXT (object);
|
MetaContext *context = META_CONTEXT (object);
|
||||||
MetaContextPrivate *priv = meta_context_get_instance_private (context);
|
MetaContextPrivate *priv = meta_context_get_instance_private (context);
|
||||||
|
MetaBackend *backend;
|
||||||
|
|
||||||
|
backend = meta_get_backend ();
|
||||||
|
if (backend)
|
||||||
|
meta_backend_prepare_shutdown (backend);
|
||||||
|
|
||||||
|
meta_release_backend ();
|
||||||
|
|
||||||
g_clear_pointer (&priv->name, g_free);
|
g_clear_pointer (&priv->name, g_free);
|
||||||
|
|
||||||
@ -135,6 +178,8 @@ meta_context_class_init (MetaContextClass *klass)
|
|||||||
object_class->set_property = meta_context_set_property;
|
object_class->set_property = meta_context_set_property;
|
||||||
object_class->finalize = meta_context_finalize;
|
object_class->finalize = meta_context_finalize;
|
||||||
|
|
||||||
|
klass->setup = meta_context_real_setup;
|
||||||
|
|
||||||
obj_props[PROP_NAME] =
|
obj_props[PROP_NAME] =
|
||||||
g_param_spec_string ("name",
|
g_param_spec_string ("name",
|
||||||
"name",
|
"name",
|
||||||
|
@ -35,4 +35,8 @@ gboolean meta_context_configure (MetaContext *context,
|
|||||||
char ***argv,
|
char ***argv,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
META_EXPORT
|
||||||
|
gboolean meta_context_setup (MetaContext *context,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
#endif /* META_CONTEXT_H */
|
#endif /* META_CONTEXT_H */
|
||||||
|
@ -66,6 +66,17 @@ meta_context_test_get_compositor_type (MetaContext *context)
|
|||||||
return META_COMPOSITOR_TYPE_WAYLAND;
|
return META_COMPOSITOR_TYPE_WAYLAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
meta_context_test_setup (MetaContext *context,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
if (!META_CONTEXT_CLASS (meta_context_test_parent_class)->setup (context,
|
||||||
|
error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static MetaBackend *
|
static MetaBackend *
|
||||||
create_nested_backend (MetaContext *context,
|
create_nested_backend (MetaContext *context,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -126,6 +137,7 @@ meta_context_test_class_init (MetaContextTestClass *klass)
|
|||||||
|
|
||||||
context_class->configure = meta_context_test_configure;
|
context_class->configure = meta_context_test_configure;
|
||||||
context_class->get_compositor_type = meta_context_test_get_compositor_type;
|
context_class->get_compositor_type = meta_context_test_get_compositor_type;
|
||||||
|
context_class->setup = meta_context_test_setup;
|
||||||
context_class->create_backend = meta_context_test_create_backend;
|
context_class->create_backend = meta_context_test_create_backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user