mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
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
This commit is contained in:
parent
3803fd9511
commit
18a21b67c2
@ -35,8 +35,6 @@
|
|||||||
|
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
|
|
||||||
#include "xserver-server-protocol.h"
|
|
||||||
|
|
||||||
#include "meta-wayland-private.h"
|
#include "meta-wayland-private.h"
|
||||||
#include "meta-xwayland-private.h"
|
#include "meta-xwayland-private.h"
|
||||||
#include "meta-wayland-stage.h"
|
#include "meta-wayland-stage.h"
|
||||||
@ -1142,87 +1140,6 @@ bind_shell (struct wl_client *client,
|
|||||||
wl_resource_set_implementation (resource, &meta_wayland_shell_interface, data, NULL);
|
wl_resource_set_implementation (resource, &meta_wayland_shell_interface, data, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
static void
|
||||||
stage_destroy_cb (void)
|
stage_destroy_cb (void)
|
||||||
{
|
{
|
||||||
@ -1544,10 +1461,6 @@ meta_wayland_init (void)
|
|||||||
if (wl_display_add_socket (compositor->wayland_display, "wayland-0"))
|
if (wl_display_add_socket (compositor->wayland_display, "wayland-0"))
|
||||||
g_error ("Failed to create socket");
|
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
|
/* XXX: It's important that we only try and start xwayland after we
|
||||||
* have initialized EGL because EGL implements the "wl_drm"
|
* have initialized EGL because EGL implements the "wl_drm"
|
||||||
* interface which xwayland requires to determine what drm device
|
* interface which xwayland requires to determine what drm device
|
||||||
@ -1562,13 +1475,6 @@ meta_wayland_init (void)
|
|||||||
g_error ("Failed to start X Wayland");
|
g_error ("Failed to start X Wayland");
|
||||||
|
|
||||||
putenv (g_strdup_printf ("DISPLAY=:%d", compositor->xwayland_display_index));
|
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
|
void
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
* 02111-1307, USA.
|
* 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "meta-xwayland-private.h"
|
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -31,6 +29,91 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <stdlib.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 *
|
static char *
|
||||||
create_lockfile (int display, int *display_out)
|
create_lockfile (int display, int *display_out)
|
||||||
{
|
{
|
||||||
@ -231,6 +314,10 @@ meta_xwayland_start (MetaWaylandCompositor *compositor)
|
|||||||
char *args[11];
|
char *args[11];
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
|
wl_global_create (compositor->wayland_display,
|
||||||
|
&xserver_interface, 1,
|
||||||
|
compositor, bind_xserver);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
lockfile = create_lockfile (display, &display);
|
lockfile = create_lockfile (display, &display);
|
||||||
@ -328,6 +415,13 @@ meta_xwayland_start (MetaWaylandCompositor *compositor)
|
|||||||
g_strfreev (env);
|
g_strfreev (env);
|
||||||
g_free (display_name);
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user