summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagn@redhat.com>2013-08-12 10:06:13 +0200
committerGiovanni Campagna <gcampagn@redhat.com>2013-08-15 17:42:19 +0200
commit18a21b67c271c75f8f2cb0e0035ee1f08e74fa92 (patch)
tree054d71e20cb40c27e62dcf0184588281033dd40e
parent3803fd9511eb5341412507fa706f8098a37e4897 (diff)
downloadmutter-18a21b67c271c75f8f2cb0e0035ee1f08e74fa92.tar.gz
wayland: move XWayland support code to its own file
Given that xwayland code is already split in meta-xwayland, it makes sense to have there the implementation of the private xserver protocol too. https://bugzilla.gnome.org/show_bug.cgi?id=705816
-rw-r--r--src/wayland/meta-wayland.c94
-rw-r--r--src/wayland/meta-xwayland.c98
2 files changed, 96 insertions, 96 deletions
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 159499e1c..5b62e8967 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -35,8 +35,6 @@
#include <wayland-server.h>
-#include "xserver-server-protocol.h"
-
#include "meta-wayland-private.h"
#include "meta-xwayland-private.h"
#include "meta-wayland-stage.h"
@@ -1143,87 +1141,6 @@ bind_shell (struct wl_client *client,
}
static void
-xserver_set_window_id (struct wl_client *client,
- struct wl_resource *compositor_resource,
- struct wl_resource *surface_resource,
- guint32 xid)
-{
- MetaWaylandCompositor *compositor =
- wl_resource_get_user_data (compositor_resource);
- MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
- MetaDisplay *display = meta_get_display ();
- MetaWindow *window;
-
- g_return_if_fail (surface->xid == None);
-
- surface->xid = xid;
-
- window = meta_display_lookup_x_window (display, xid);
- if (window)
- {
- MetaWindowActor *window_actor =
- META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
-
- meta_window_actor_set_wayland_surface (window_actor, surface);
-
- surface->window = window;
- window->surface = surface;
-
- /* If the window is already meant to have focus then the
- * original attempt to call this in response to the FocusIn
- * event will have been lost because there was no surface
- * yet. */
- if (window->has_focus)
- meta_wayland_compositor_set_input_focus (compositor, window);
-
- }
-}
-
-static const struct xserver_interface xserver_implementation = {
- xserver_set_window_id
-};
-
-static void
-bind_xserver (struct wl_client *client,
- void *data,
- guint32 version,
- guint32 id)
-{
- MetaWaylandCompositor *compositor = data;
-
- /* If it's a different client than the xserver we launched,
- * don't start the wm. */
- if (client != compositor->xwayland_client)
- return;
-
- compositor->xserver_resource =
- wl_resource_create (client, &xserver_interface, version, id);
- wl_resource_set_implementation (compositor->xserver_resource,
- &xserver_implementation, compositor, NULL);
-
- wl_resource_post_event (compositor->xserver_resource,
- XSERVER_LISTEN_SOCKET,
- compositor->xwayland_abstract_fd);
-
- wl_resource_post_event (compositor->xserver_resource,
- XSERVER_LISTEN_SOCKET,
- compositor->xwayland_unix_fd);
-
- /* Make sure xwayland will recieve the above sockets in a finite
- * time before unblocking the initialization mainloop since we are
- * then going to immediately try and connect to those as the window
- * manager. */
- wl_client_flush (client);
-
- /* At this point xwayland is all setup to start accepting
- * connections so we can quit the transient initialization mainloop
- * and unblock meta_wayland_init() to continue initializing mutter.
- * */
- g_main_loop_quit (compositor->init_loop);
- compositor->init_loop = NULL;
-}
-
-static void
stage_destroy_cb (void)
{
meta_quit (META_EXIT_SUCCESS);
@@ -1544,10 +1461,6 @@ meta_wayland_init (void)
if (wl_display_add_socket (compositor->wayland_display, "wayland-0"))
g_error ("Failed to create socket");
- wl_global_create (compositor->wayland_display,
- &xserver_interface, 1,
- compositor, bind_xserver);
-
/* XXX: It's important that we only try and start xwayland after we
* have initialized EGL because EGL implements the "wl_drm"
* interface which xwayland requires to determine what drm device
@@ -1562,13 +1475,6 @@ meta_wayland_init (void)
g_error ("Failed to start X Wayland");
putenv (g_strdup_printf ("DISPLAY=:%d", compositor->xwayland_display_index));
-
- /* 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
- * ready to start accepting connections. */
- compositor->init_loop = g_main_loop_new (NULL, FALSE);
-
- g_main_loop_run (compositor->init_loop);
}
void
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index 56d3b7152..d78b199bc 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -19,8 +19,6 @@
* 02111-1307, USA.
*/
-#include "meta-xwayland-private.h"
-
#include <glib.h>
#include <unistd.h>
@@ -31,6 +29,91 @@
#include <sys/wait.h>
#include <stdlib.h>
+#include "meta-xwayland-private.h"
+#include "meta-window-actor-private.h"
+#include "xserver-server-protocol.h"
+
+static void
+xserver_set_window_id (struct wl_client *client,
+ struct wl_resource *compositor_resource,
+ struct wl_resource *surface_resource,
+ guint32 xid)
+{
+ MetaWaylandCompositor *compositor =
+ wl_resource_get_user_data (compositor_resource);
+ MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
+ MetaDisplay *display = meta_get_display ();
+ MetaWindow *window;
+
+ g_return_if_fail (surface->xid == None);
+
+ surface->xid = xid;
+
+ window = meta_display_lookup_x_window (display, xid);
+ if (window)
+ {
+ MetaWindowActor *window_actor =
+ META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
+
+ meta_window_actor_set_wayland_surface (window_actor, surface);
+
+ surface->window = window;
+ window->surface = surface;
+
+ /* If the window is already meant to have focus then the
+ * original attempt to call this in response to the FocusIn
+ * event will have been lost because there was no surface
+ * yet. */
+ if (window->has_focus)
+ meta_wayland_compositor_set_input_focus (compositor, window);
+
+ }
+}
+
+static const struct xserver_interface xserver_implementation = {
+ xserver_set_window_id
+};
+
+static void
+bind_xserver (struct wl_client *client,
+ void *data,
+ guint32 version,
+ guint32 id)
+{
+ MetaWaylandCompositor *compositor = data;
+
+ /* If it's a different client than the xserver we launched,
+ * don't start the wm. */
+ if (client != compositor->xwayland_client)
+ return;
+
+ compositor->xserver_resource =
+ wl_resource_create (client, &xserver_interface, version, id);
+ wl_resource_set_implementation (compositor->xserver_resource,
+ &xserver_implementation, compositor, NULL);
+
+ wl_resource_post_event (compositor->xserver_resource,
+ XSERVER_LISTEN_SOCKET,
+ compositor->xwayland_abstract_fd);
+
+ wl_resource_post_event (compositor->xserver_resource,
+ XSERVER_LISTEN_SOCKET,
+ compositor->xwayland_unix_fd);
+
+ /* Make sure xwayland will recieve the above sockets in a finite
+ * time before unblocking the initialization mainloop since we are
+ * then going to immediately try and connect to those as the window
+ * manager. */
+ wl_client_flush (client);
+
+ /* At this point xwayland is all setup to start accepting
+ * connections so we can quit the transient initialization mainloop
+ * and unblock meta_wayland_init() to continue initializing mutter.
+ * */
+ g_main_loop_quit (compositor->init_loop);
+ compositor->init_loop = NULL;
+}
+
static char *
create_lockfile (int display, int *display_out)
{
@@ -231,6 +314,10 @@ meta_xwayland_start (MetaWaylandCompositor *compositor)
char *args[11];
GError *error;
+ wl_global_create (compositor->wayland_display,
+ &xserver_interface, 1,
+ compositor, bind_xserver);
+
do
{
lockfile = create_lockfile (display, &display);
@@ -328,6 +415,13 @@ meta_xwayland_start (MetaWaylandCompositor *compositor)
g_strfreev (env);
g_free (display_name);
+ /* 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
+ * ready to start accepting connections. */
+ compositor->init_loop = g_main_loop_new (NULL, FALSE);
+
+ g_main_loop_run (compositor->init_loop);
+
return TRUE;
}