Add --no-x11 flag so mutter wayland can be started without X11

https://bugzilla.gnome.org/show_bug.cgi?id=759538
This commit is contained in:
Armin Krezović 2017-08-27 20:44:58 +02:00 committed by Jonas Ådahl
parent e8171ccdc1
commit d5c5669f2a
4 changed files with 51 additions and 8 deletions

View File

@ -35,6 +35,7 @@
#include "events.h" #include "events.h"
#include "util-private.h" #include "util-private.h"
#include <meta/main.h> #include <meta/main.h>
#include "main-private.h"
#include "window-private.h" #include "window-private.h"
#include "boxes-private.h" #include "boxes-private.h"
#include "frame.h" #include "frame.h"
@ -813,12 +814,19 @@ meta_display_open (void)
display->bell = meta_bell_new (display); display->bell = meta_bell_new (display);
x11_display = meta_x11_display_new (display, &error); if (meta_should_autostart_x11_display ())
g_assert (x11_display != NULL); /* Required, for now */ {
display->x11_display = x11_display; x11_display = meta_x11_display_new (display, &error);
g_signal_emit (display, display_signals[X11_DISPLAY_OPENED], 0); g_assert (x11_display != NULL); /* Required, for now */
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;
}
else
{
timestamp = meta_display_get_current_time_roundtrip (display);
}
display->last_focus_time = timestamp; display->last_focus_time = timestamp;
display->last_user_time = timestamp; display->last_user_time = timestamp;

View File

@ -31,4 +31,6 @@ typedef enum _MetaCompositorType
void meta_override_compositor_configuration (MetaCompositorType compositor_type, void meta_override_compositor_configuration (MetaCompositorType compositor_type,
GType backend_gtype); GType backend_gtype);
gboolean meta_should_autostart_x11_display (void);
#endif /* META_MAIN_PRIVATE_H */ #endif /* META_MAIN_PRIVATE_H */

View File

@ -177,6 +177,7 @@ static gboolean opt_sync;
#ifdef HAVE_WAYLAND #ifdef HAVE_WAYLAND
static gboolean opt_wayland; static gboolean opt_wayland;
static gboolean opt_nested; static gboolean opt_nested;
static gboolean opt_no_x11;
#endif #endif
#ifdef HAVE_NATIVE_BACKEND #ifdef HAVE_NATIVE_BACKEND
static gboolean opt_display_server; static gboolean opt_display_server;
@ -232,6 +233,12 @@ static GOptionEntry meta_options[] = {
N_("Run as a nested compositor"), N_("Run as a nested compositor"),
NULL NULL
}, },
{
"no-x11", 0, 0, G_OPTION_ARG_NONE,
&opt_no_x11,
N_("Run wayland compositor without starting Xwayland"),
NULL
},
#endif #endif
#ifdef HAVE_NATIVE_BACKEND #ifdef HAVE_NATIVE_BACKEND
{ {
@ -453,6 +460,12 @@ calculate_compositor_configuration (MetaCompositorType *compositor_type,
run_as_wayland_compositor = check_for_wayland_session_type (); run_as_wayland_compositor = check_for_wayland_session_type ();
#endif /* HAVE_NATIVE_BACKEND */ #endif /* HAVE_NATIVE_BACKEND */
if (!run_as_wayland_compositor && opt_no_x11)
{
meta_warning ("Can't disable X11 support on X11 compositor\n");
meta_exit (META_EXIT_ERROR);
}
if (run_as_wayland_compositor) if (run_as_wayland_compositor)
*compositor_type = META_COMPOSITOR_TYPE_WAYLAND; *compositor_type = META_COMPOSITOR_TYPE_WAYLAND;
else else
@ -709,3 +722,16 @@ prefs_changed_callback (MetaPreference pref,
break; break;
} }
} }
gboolean
meta_should_autostart_x11_display (void)
{
MetaBackend *backend = meta_get_backend ();
gboolean wants_x11 = TRUE;
#ifdef HAVE_WAYLAND
wants_x11 = !opt_no_x11;
#endif
return META_IS_BACKEND_X11_CM (backend) || wants_x11;
}

View File

@ -49,6 +49,8 @@
#include "meta-xwayland.h" #include "meta-xwayland.h"
#include "meta-wayland-egl-stream.h" #include "meta-wayland-egl-stream.h"
#include "main-private.h"
static MetaWaylandCompositor _meta_wayland_compositor; static MetaWaylandCompositor _meta_wayland_compositor;
static char *_display_name_override; static char *_display_name_override;
@ -400,8 +402,11 @@ meta_wayland_init (void)
meta_wayland_eglstream_controller_init (compositor); meta_wayland_eglstream_controller_init (compositor);
if (!meta_xwayland_start (&compositor->xwayland_manager, compositor->wayland_display)) if (meta_should_autostart_x11_display ())
g_error ("Failed to start X Wayland"); {
if (!meta_xwayland_start (&compositor->xwayland_manager, compositor->wayland_display))
g_error ("Failed to start X Wayland");
}
if (_display_name_override) if (_display_name_override)
{ {
@ -422,7 +427,9 @@ meta_wayland_init (void)
compositor->display_name = g_strdup (display_name); compositor->display_name = g_strdup (display_name);
} }
set_gnome_env ("DISPLAY", meta_wayland_get_xwayland_display_name (compositor)); if (meta_should_autostart_x11_display ())
set_gnome_env ("DISPLAY", meta_wayland_get_xwayland_display_name (compositor));
set_gnome_env ("WAYLAND_DISPLAY", meta_wayland_get_wayland_display_name (compositor)); set_gnome_env ("WAYLAND_DISPLAY", meta_wayland_get_wayland_display_name (compositor));
} }