mirror of
https://github.com/brl/mutter.git
synced 2024-11-13 01:36:10 -05:00
xwayland: Split out the XWayland stuff into its own private struct
This commit is contained in:
parent
0ce64e46e8
commit
8566566451
@ -115,7 +115,7 @@ inform_clients_of_new_keymap (MetaWaylandKeyboard *keyboard,
|
|||||||
struct wl_resource *keyboard_resource;
|
struct wl_resource *keyboard_resource;
|
||||||
|
|
||||||
compositor = meta_wayland_compositor_get_default ();
|
compositor = meta_wayland_compositor_get_default ();
|
||||||
xclient = compositor->xwayland_client;
|
xclient = compositor->xwayland_manager.client;
|
||||||
|
|
||||||
wl_resource_for_each (keyboard_resource, &keyboard->resource_list)
|
wl_resource_for_each (keyboard_resource, &keyboard->resource_list)
|
||||||
{
|
{
|
||||||
|
@ -59,25 +59,31 @@ typedef struct
|
|||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
} MetaWaylandFrameCallback;
|
} MetaWaylandFrameCallback;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int display_index;
|
||||||
|
char *lockfile;
|
||||||
|
int abstract_fd;
|
||||||
|
int unix_fd;
|
||||||
|
pid_t pid;
|
||||||
|
struct wl_client *client;
|
||||||
|
struct wl_resource *xserver_resource;
|
||||||
|
|
||||||
|
GMainLoop *init_loop;
|
||||||
|
} MetaXWaylandManager;
|
||||||
|
|
||||||
struct _MetaWaylandCompositor
|
struct _MetaWaylandCompositor
|
||||||
{
|
{
|
||||||
struct wl_display *wayland_display;
|
struct wl_display *wayland_display;
|
||||||
char *display_name;
|
char *display_name;
|
||||||
struct wl_event_loop *wayland_loop;
|
struct wl_event_loop *wayland_loop;
|
||||||
GMainLoop *init_loop;
|
|
||||||
ClutterActor *stage;
|
ClutterActor *stage;
|
||||||
GHashTable *outputs;
|
GHashTable *outputs;
|
||||||
GSource *wayland_event_source;
|
GSource *wayland_event_source;
|
||||||
GList *surfaces;
|
GList *surfaces;
|
||||||
struct wl_list frame_callbacks;
|
struct wl_list frame_callbacks;
|
||||||
|
|
||||||
int xwayland_display_index;
|
MetaXWaylandManager xwayland_manager;
|
||||||
char *xwayland_lockfile;
|
|
||||||
int xwayland_abstract_fd;
|
|
||||||
int xwayland_unix_fd;
|
|
||||||
pid_t xwayland_pid;
|
|
||||||
struct wl_client *xwayland_client;
|
|
||||||
struct wl_resource *xserver_resource;
|
|
||||||
|
|
||||||
MetaLauncher *launcher;
|
MetaLauncher *launcher;
|
||||||
gboolean native;
|
gboolean native;
|
||||||
|
@ -720,12 +720,10 @@ meta_wayland_init (void)
|
|||||||
* and so EGL must be initialized by this point.
|
* and so EGL must be initialized by this point.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!meta_xwayland_start (compositor))
|
if (!meta_xwayland_start (&compositor->xwayland_manager, compositor->wayland_display, &display_name))
|
||||||
g_error ("Failed to start X Wayland");
|
g_error ("Failed to start X Wayland");
|
||||||
|
|
||||||
display_name = g_strdup_printf (":%d", compositor->xwayland_display_index);
|
|
||||||
set_gnome_env ("DISPLAY", display_name);
|
set_gnome_env ("DISPLAY", display_name);
|
||||||
g_free (display_name);
|
|
||||||
|
|
||||||
set_gnome_env ("WAYLAND_DISPLAY", compositor->display_name);
|
set_gnome_env ("WAYLAND_DISPLAY", compositor->display_name);
|
||||||
}
|
}
|
||||||
@ -737,7 +735,7 @@ meta_wayland_finalize (void)
|
|||||||
|
|
||||||
compositor = meta_wayland_compositor_get_default ();
|
compositor = meta_wayland_compositor_get_default ();
|
||||||
|
|
||||||
meta_xwayland_stop (compositor);
|
meta_xwayland_stop (&compositor->xwayland_manager);
|
||||||
|
|
||||||
if (compositor->launcher)
|
if (compositor->launcher)
|
||||||
meta_launcher_free (compositor->launcher);
|
meta_launcher_free (compositor->launcher);
|
||||||
|
@ -25,12 +25,14 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
meta_xwayland_start (MetaWaylandCompositor *compositor);
|
meta_xwayland_start (MetaXWaylandManager *manager,
|
||||||
|
struct wl_display *display,
|
||||||
|
char **display_name_out);
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_xwayland_complete_init (void);
|
meta_xwayland_complete_init (void);
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_xwayland_stop (MetaWaylandCompositor *compositor);
|
meta_xwayland_stop (MetaXWaylandManager *manager);
|
||||||
|
|
||||||
#endif /* META_XWAYLAND_PRIVATE_H */
|
#endif /* META_XWAYLAND_PRIVATE_H */
|
||||||
|
@ -63,20 +63,20 @@ bind_xserver (struct wl_client *client,
|
|||||||
guint32 version,
|
guint32 version,
|
||||||
guint32 id)
|
guint32 id)
|
||||||
{
|
{
|
||||||
MetaWaylandCompositor *compositor = data;
|
MetaXWaylandManager *manager = data;
|
||||||
|
|
||||||
/* If it's a different client than the xserver we launched,
|
/* If it's a different client than the xserver we launched,
|
||||||
* don't start the wm. */
|
* just freeze up... */
|
||||||
if (client != compositor->xwayland_client)
|
if (client != manager->client)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
compositor->xserver_resource = wl_resource_create (client, &xserver_interface,
|
manager->xserver_resource = wl_resource_create (client, &xserver_interface,
|
||||||
MIN (META_XSERVER_VERSION, version), id);
|
MIN (META_XSERVER_VERSION, version), id);
|
||||||
wl_resource_set_implementation (compositor->xserver_resource,
|
wl_resource_set_implementation (manager->xserver_resource,
|
||||||
&xserver_implementation, compositor, NULL);
|
&xserver_implementation, manager, NULL);
|
||||||
|
|
||||||
xserver_send_listen_socket (compositor->xserver_resource, compositor->xwayland_abstract_fd);
|
xserver_send_listen_socket (manager->xserver_resource, manager->abstract_fd);
|
||||||
xserver_send_listen_socket (compositor->xserver_resource, compositor->xwayland_unix_fd);
|
xserver_send_listen_socket (manager->xserver_resource, manager->unix_fd);
|
||||||
|
|
||||||
/* Make sure xwayland will recieve the above sockets in a finite
|
/* Make sure xwayland will recieve the above sockets in a finite
|
||||||
* time before unblocking the initialization mainloop since we are
|
* time before unblocking the initialization mainloop since we are
|
||||||
@ -88,8 +88,8 @@ bind_xserver (struct wl_client *client,
|
|||||||
* connections so we can quit the transient initialization mainloop
|
* connections so we can quit the transient initialization mainloop
|
||||||
* and unblock meta_wayland_init() to continue initializing mutter.
|
* and unblock meta_wayland_init() to continue initializing mutter.
|
||||||
* */
|
* */
|
||||||
g_main_loop_quit (compositor->init_loop);
|
g_main_loop_quit (manager->init_loop);
|
||||||
g_clear_pointer (&compositor->init_loop, g_main_loop_unref);
|
g_clear_pointer (&manager->init_loop, g_main_loop_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@ -285,7 +285,9 @@ x_io_error (Display *display)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
meta_xwayland_start (MetaWaylandCompositor *compositor)
|
meta_xwayland_start (MetaXWaylandManager *manager,
|
||||||
|
struct wl_display *wl_display,
|
||||||
|
char **display_name_out)
|
||||||
{
|
{
|
||||||
int display = 0;
|
int display = 0;
|
||||||
char *lockfile = NULL;
|
char *lockfile = NULL;
|
||||||
@ -298,10 +300,9 @@ meta_xwayland_start (MetaWaylandCompositor *compositor)
|
|||||||
char *args[11];
|
char *args[11];
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
wl_global_create (compositor->wayland_display,
|
wl_global_create (wl_display, &xserver_interface,
|
||||||
&xserver_interface,
|
|
||||||
META_XSERVER_VERSION,
|
META_XSERVER_VERSION,
|
||||||
compositor, bind_xserver);
|
manager, bind_xserver);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -312,8 +313,8 @@ meta_xwayland_start (MetaWaylandCompositor *compositor)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
compositor->xwayland_abstract_fd = bind_to_abstract_socket (display);
|
manager->abstract_fd = bind_to_abstract_socket (display);
|
||||||
if (compositor->xwayland_abstract_fd < 0)
|
if (manager->abstract_fd < 0)
|
||||||
{
|
{
|
||||||
unlink (lockfile);
|
unlink (lockfile);
|
||||||
|
|
||||||
@ -326,11 +327,11 @@ meta_xwayland_start (MetaWaylandCompositor *compositor)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
compositor->xwayland_unix_fd = bind_to_unix_socket (display);
|
manager->unix_fd = bind_to_unix_socket (display);
|
||||||
if (compositor->xwayland_abstract_fd < 0)
|
if (manager->abstract_fd < 0)
|
||||||
{
|
{
|
||||||
unlink (lockfile);
|
unlink (lockfile);
|
||||||
close (compositor->xwayland_abstract_fd);
|
close (manager->abstract_fd);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,8 +339,8 @@ meta_xwayland_start (MetaWaylandCompositor *compositor)
|
|||||||
}
|
}
|
||||||
while (1);
|
while (1);
|
||||||
|
|
||||||
compositor->xwayland_display_index = display;
|
manager->display_index = display;
|
||||||
compositor->xwayland_lockfile = lockfile;
|
manager->lockfile = lockfile;
|
||||||
|
|
||||||
/* 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. */
|
||||||
@ -355,8 +356,7 @@ meta_xwayland_start (MetaWaylandCompositor *compositor)
|
|||||||
env = g_environ_setenv (env, "WAYLAND_SOCKET", fd_string, TRUE);
|
env = g_environ_setenv (env, "WAYLAND_SOCKET", fd_string, TRUE);
|
||||||
g_free (fd_string);
|
g_free (fd_string);
|
||||||
|
|
||||||
display_name = g_strdup_printf (":%d",
|
display_name = g_strdup_printf (":%d", manager->display_index);
|
||||||
compositor->xwayland_display_index);
|
|
||||||
log_path = g_build_filename (g_get_user_cache_dir (), "xwayland.log", NULL);
|
log_path = g_build_filename (g_get_user_cache_dir (), "xwayland.log", NULL);
|
||||||
|
|
||||||
args[0] = XWAYLAND_PATH;
|
args[0] = XWAYLAND_PATH;
|
||||||
@ -387,10 +387,9 @@ meta_xwayland_start (MetaWaylandCompositor *compositor)
|
|||||||
g_message ("forked X server, pid %d\n", pid);
|
g_message ("forked X server, pid %d\n", pid);
|
||||||
|
|
||||||
close (sp[1]);
|
close (sp[1]);
|
||||||
compositor->xwayland_client =
|
manager->client = wl_client_create (wl_display, sp[0]);
|
||||||
wl_client_create (compositor->wayland_display, sp[0]);
|
|
||||||
|
|
||||||
compositor->xwayland_pid = pid;
|
manager->pid = pid;
|
||||||
g_child_watch_add (pid, xserver_died, NULL);
|
g_child_watch_add (pid, xserver_died, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -405,9 +404,10 @@ meta_xwayland_start (MetaWaylandCompositor *compositor)
|
|||||||
/* 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
|
||||||
* ready to start accepting connections. */
|
* ready to start accepting connections. */
|
||||||
compositor->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 (compositor->init_loop);
|
*display_name_out = display_name;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -425,16 +425,14 @@ meta_xwayland_complete_init (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_xwayland_stop (MetaWaylandCompositor *compositor)
|
meta_xwayland_stop (MetaXWaylandManager *manager)
|
||||||
{
|
{
|
||||||
char path[256];
|
char path[256];
|
||||||
|
|
||||||
snprintf (path, sizeof path, "/tmp/.X%d-lock",
|
snprintf (path, sizeof path, "/tmp/.X%d-lock", manager->display_index);
|
||||||
compositor->xwayland_display_index);
|
|
||||||
unlink (path);
|
unlink (path);
|
||||||
snprintf (path, sizeof path, "/tmp/.X11-unix/X%d",
|
snprintf (path, sizeof path, "/tmp/.X11-unix/X%d", manager->display_index);
|
||||||
compositor->xwayland_display_index);
|
|
||||||
unlink (path);
|
unlink (path);
|
||||||
|
|
||||||
unlink (compositor->xwayland_lockfile);
|
unlink (manager->lockfile);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user