core: Add explicit init/shutdown_x11() MetaDisplay calls

The lifetime of MetaX11Display is still tied to MetaDisplay, but these
calls will be useful when it's actually affordable to decouple those.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
This commit is contained in:
Carlos Garnacho 2018-12-10 13:40:54 +01:00 committed by Jonas Ådahl
parent 86de79cfc5
commit 465e13128b
2 changed files with 40 additions and 11 deletions

View File

@ -427,4 +427,8 @@ MetaWindow *meta_display_get_window_from_id (MetaDisplay *display,
uint64_t window_id); uint64_t window_id);
uint64_t meta_display_generate_window_id (MetaDisplay *display); uint64_t meta_display_generate_window_id (MetaDisplay *display);
gboolean meta_display_init_x11 (MetaDisplay *display,
GError **error);
void meta_display_shutdown_x11 (MetaDisplay *display);
#endif #endif

View File

@ -631,6 +631,39 @@ on_ui_scaling_factor_changed (MetaSettings *settings,
meta_display_reload_cursor (display); meta_display_reload_cursor (display);
} }
gboolean
meta_display_init_x11 (MetaDisplay *display,
GError **error)
{
MetaX11Display *x11_display;
g_assert (display->x11_display == NULL);
x11_display = meta_x11_display_new (display, error);
if (!x11_display)
return FALSE;
display->x11_display = x11_display;
g_signal_emit (display, display_signals[X11_DISPLAY_OPENED], 0);
meta_x11_display_create_guard_window (x11_display);
if (!display->display_opening)
meta_display_manage_all_windows (display);
return TRUE;
}
void
meta_display_shutdown_x11 (MetaDisplay *display)
{
if (!display->x11_display)
return;
g_signal_emit (display, display_signals[X11_DISPLAY_CLOSING], 0);
g_object_run_dispose (G_OBJECT (display->x11_display));
g_clear_object (&display->x11_display);
}
/** /**
* meta_display_open: * meta_display_open:
* *
@ -646,7 +679,6 @@ meta_display_open (void)
{ {
GError *error = NULL; GError *error = NULL;
MetaDisplay *display; MetaDisplay *display;
MetaX11Display *x11_display;
int i; int i;
guint32 timestamp; guint32 timestamp;
Window old_active_xwindow = None; Window old_active_xwindow = None;
@ -730,10 +762,8 @@ meta_display_open (void)
if (meta_should_autostart_x11_display ()) if (meta_should_autostart_x11_display ())
{ {
x11_display = meta_x11_display_new (display, &error); if (!meta_display_init_x11 (display, &error))
g_assert (x11_display != NULL); /* Required, for now */ g_error ("Failed to start Xwayland: %s", error->message);
display->x11_display = x11_display;
g_signal_emit (display, display_signals[X11_DISPLAY_OPENED], 0);
timestamp = display->x11_display->timestamp; timestamp = display->x11_display->timestamp;
} }
@ -955,12 +985,7 @@ meta_display_close (MetaDisplay *display,
if (display->compositor) if (display->compositor)
meta_compositor_destroy (display->compositor); meta_compositor_destroy (display->compositor);
if (display->x11_display) meta_display_shutdown_x11 (display);
{
g_signal_emit (display, display_signals[X11_DISPLAY_CLOSING], 0);
g_object_run_dispose (G_OBJECT (display->x11_display));
g_clear_object (&display->x11_display);
}
meta_display_shutdown_keys (display); meta_display_shutdown_keys (display);