[mutter] main: Clean up the initialization sequence
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] main: Clean up the initialization sequence
- Date: Mon, 18 Aug 2014 21:00:05 +0000 (UTC)
commit a7b1b1da80cfd2b8b01ff751fa218f525ac0d5e5
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Aug 18 16:54:15 2014 -0400
main: Clean up the initialization sequence
The initialization sequence before was quite icky, initializing Clutter
in a few different places depending on what was going on.
Put that all back into main.c
src/core/main.c | 26 +++++++++++++-------------
src/wayland/meta-wayland.c | 32 +++++++++++++++++++++-----------
src/wayland/meta-wayland.h | 1 +
3 files changed, 35 insertions(+), 24 deletions(-)
---
diff --git a/src/core/main.c b/src/core/main.c
index 1e60b44..1397217 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -348,15 +348,22 @@ meta_init (void)
#ifdef HAVE_WAYLAND
if (meta_is_wayland_compositor ())
- {
- /* NB: When running as a hybrid wayland compositor we run our own headless X
- * server so the user can't control the X display to connect too. */
- meta_wayland_init ();
- }
- else
+ meta_wayland_pre_clutter_init ();
#endif
+
+ /* NB: When running as a hybrid wayland compositor we run our own headless X
+ * server so the user can't control the X display to connect too. */
+ if (!meta_is_wayland_compositor ())
meta_select_display (opt_display_name);
+ meta_clutter_init ();
+
+#ifdef HAVE_WAYLAND
+ /* Bring up Wayland. This also launches Xwayland and sets DISPLAY as well... */
+ if (meta_is_wayland_compositor ())
+ meta_wayland_init ();
+#endif
+
meta_set_syncing (opt_sync || (g_getenv ("MUTTER_SYNC") != NULL));
if (opt_replace_wm)
@@ -367,13 +374,6 @@ meta_init (void)
meta_main_loop = g_main_loop_new (NULL, FALSE);
- /* If we are running with wayland then we don't wait until we have
- * an X connection before initializing clutter we instead initialize
- * it earlier since we need to initialize the GL driver so the driver
- * can register any needed wayland extensions. */
- if (!meta_is_wayland_compositor ())
- meta_clutter_init ();
-
meta_ui_init ();
meta_restart_init ();
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 7ab82fb..5b58a18 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -371,28 +371,41 @@ meta_wayland_log_func (const char *fmt,
g_free (str);
}
+static void
+meta_wayland_compositor_init (MetaWaylandCompositor *compositor)
+{
+ memset (compositor, 0, sizeof (MetaWaylandCompositor));
+ wl_list_init (&compositor->frame_callbacks);
+}
+
void
-meta_wayland_init (void)
+meta_wayland_pre_clutter_init (void)
{
MetaWaylandCompositor *compositor = &_meta_wayland_compositor;
- GSource *wayland_event_source;
- memset (compositor, 0, sizeof (MetaWaylandCompositor));
+ meta_wayland_compositor_init (compositor);
+
+ /* Set up our logging. */
+ wl_log_set_handler_server (meta_wayland_log_func);
compositor->wayland_display = wl_display_create ();
if (compositor->wayland_display == NULL)
- g_error ("failed to create wayland display");
+ g_error ("Failed to create the global wl_display");
- wl_display_init_shm (compositor->wayland_display);
- wl_log_set_handler_server (meta_wayland_log_func);
+ clutter_wayland_set_compositor_display (compositor->wayland_display);
+}
- wl_list_init (&compositor->frame_callbacks);
+void
+meta_wayland_init (void)
+{
+ MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
+ GSource *wayland_event_source;
if (!wl_global_create (compositor->wayland_display,
&wl_compositor_interface,
META_WL_COMPOSITOR_VERSION,
compositor, compositor_bind))
- g_error ("Failed to register wayland compositor object");
+ g_error ("Failed to register the global wl_compositor");
wayland_event_source = wayland_event_source_new (compositor->wayland_display);
@@ -407,9 +420,6 @@ meta_wayland_init (void)
* synchronizing the two command streams. */
g_source_set_priority (wayland_event_source, GDK_PRIORITY_EVENTS + 1);
g_source_attach (wayland_event_source, NULL);
- clutter_wayland_set_compositor_display (compositor->wayland_display);
-
- meta_clutter_init ();
meta_wayland_outputs_init (compositor);
meta_wayland_data_device_manager_init (compositor);
diff --git a/src/wayland/meta-wayland.h b/src/wayland/meta-wayland.h
index 6feed48..860395d 100644
--- a/src/wayland/meta-wayland.h
+++ b/src/wayland/meta-wayland.h
@@ -25,6 +25,7 @@
#include "meta-wayland-types.h"
+void meta_wayland_pre_clutter_init (void);
void meta_wayland_init (void);
void meta_wayland_finalize (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]