1
0
Fork 0

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
This commit is contained in:
Jasper St. Pierre 2014-08-18 16:54:15 -04:00
parent de69678085
commit a7b1b1da80
3 changed files with 35 additions and 24 deletions

View file

@ -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 ();

View file

@ -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);

View file

@ -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);