wayland: Split Xwayland initialization in 2 steps
It is now separated into meta_xwayland_start(), which picks an unused display and sets up the sockets, and meta_xwayland_init_xserver(), which does the actual exec of Xwayland and MetaX11Display initialization. This differentiation will be useful when Mutter is able to launch Xwayland lazily, currently the former calls into the latter. https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
This commit is contained in:
parent
1cf4279745
commit
430f354cd9
@ -48,6 +48,7 @@ typedef struct
|
|||||||
char *lock_file;
|
char *lock_file;
|
||||||
int abstract_fd;
|
int abstract_fd;
|
||||||
int unix_fd;
|
int unix_fd;
|
||||||
|
struct wl_display *wayland_display;
|
||||||
struct wl_client *client;
|
struct wl_client *client;
|
||||||
struct wl_resource *xserver_resource;
|
struct wl_resource *xserver_resource;
|
||||||
char *display_name;
|
char *display_name;
|
||||||
|
@ -465,32 +465,27 @@ on_displayfd_ready (int fd,
|
|||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
static gboolean
|
||||||
meta_xwayland_start (MetaXWaylandManager *manager,
|
meta_xwayland_init_xserver (MetaXWaylandManager *manager)
|
||||||
struct wl_display *wl_display)
|
|
||||||
{
|
{
|
||||||
int xwayland_client_fd[2];
|
int xwayland_client_fd[2];
|
||||||
int displayfd[2];
|
int displayfd[2];
|
||||||
gboolean started = FALSE;
|
|
||||||
g_autoptr(GSubprocessLauncher) launcher = NULL;
|
g_autoptr(GSubprocessLauncher) launcher = NULL;
|
||||||
GSubprocessFlags flags;
|
GSubprocessFlags flags;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!choose_xdisplay (manager))
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
/* We want xwayland to be a wayland client so we make a socketpair to setup a
|
/* We want xwayland to be a wayland client so we make a socketpair to setup a
|
||||||
* wayland protocol connection. */
|
* wayland protocol connection. */
|
||||||
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, xwayland_client_fd) < 0)
|
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, xwayland_client_fd) < 0)
|
||||||
{
|
{
|
||||||
g_warning ("xwayland_client_fd socketpair failed\n");
|
g_warning ("xwayland_client_fd socketpair failed\n");
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, displayfd) < 0)
|
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, displayfd) < 0)
|
||||||
{
|
{
|
||||||
g_warning ("displayfd socketpair failed\n");
|
g_warning ("displayfd socketpair failed\n");
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* xwayland, please. */
|
/* xwayland, please. */
|
||||||
@ -530,14 +525,15 @@ meta_xwayland_start (MetaXWaylandManager *manager,
|
|||||||
if (!manager->proc)
|
if (!manager->proc)
|
||||||
{
|
{
|
||||||
g_error ("Failed to spawn Xwayland: %s", error->message);
|
g_error ("Failed to spawn Xwayland: %s", error->message);
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
manager->xserver_died_cancellable = g_cancellable_new ();
|
manager->xserver_died_cancellable = g_cancellable_new ();
|
||||||
g_subprocess_wait_async (manager->proc, manager->xserver_died_cancellable,
|
g_subprocess_wait_async (manager->proc, manager->xserver_died_cancellable,
|
||||||
xserver_died, NULL);
|
xserver_died, NULL);
|
||||||
g_unix_fd_add (displayfd[0], G_IO_IN, on_displayfd_ready, manager);
|
g_unix_fd_add (displayfd[0], G_IO_IN, on_displayfd_ready, manager);
|
||||||
manager->client = wl_client_create (wl_display, xwayland_client_fd[0]);
|
manager->client = wl_client_create (manager->wayland_display,
|
||||||
|
xwayland_client_fd[0]);
|
||||||
|
|
||||||
/* We need to run a mainloop until we know xwayland has a binding
|
/* We need to run a mainloop until we know xwayland has a binding
|
||||||
* for our xserver interface at which point we can assume it's
|
* for our xserver interface at which point we can assume it's
|
||||||
@ -545,15 +541,18 @@ meta_xwayland_start (MetaXWaylandManager *manager,
|
|||||||
manager->init_loop = g_main_loop_new (NULL, FALSE);
|
manager->init_loop = g_main_loop_new (NULL, FALSE);
|
||||||
g_main_loop_run (manager->init_loop);
|
g_main_loop_run (manager->init_loop);
|
||||||
|
|
||||||
started = TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
gboolean
|
||||||
if (!started)
|
meta_xwayland_start (MetaXWaylandManager *manager,
|
||||||
{
|
struct wl_display *wl_display)
|
||||||
unlink (manager->lock_file);
|
{
|
||||||
g_clear_pointer (&manager->lock_file, g_free);
|
if (!choose_xdisplay (manager))
|
||||||
}
|
return FALSE;
|
||||||
return started;
|
|
||||||
|
manager->wayland_display = wl_display;
|
||||||
|
return meta_xwayland_init_xserver (manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user