wayland: Add API to override display name

Add API that the tests can use in order to override the Wayland display
name.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl 2016-12-05 21:23:46 +08:00
parent 12150c1ca7
commit 239671f882
2 changed files with 26 additions and 3 deletions

View File

@ -43,6 +43,7 @@
#include "meta-wayland-xdg-foreign.h"
static MetaWaylandCompositor _meta_wayland_compositor;
static char *_display_name_override;
MetaWaylandCompositor *
meta_wayland_compositor_get_default (void)
@ -307,6 +308,12 @@ meta_wayland_pre_clutter_init (void)
clutter_wayland_set_compositor_display (compositor->wayland_display);
}
void
meta_wayland_override_display_name (char *display_name)
{
_display_name_override = g_strdup (display_name);
}
void
meta_wayland_init (void)
{
@ -345,9 +352,23 @@ meta_wayland_init (void)
if (!meta_xwayland_start (&compositor->xwayland_manager, compositor->wayland_display))
g_error ("Failed to start X Wayland");
compositor->display_name = wl_display_add_socket_auto (compositor->wayland_display);
if (_display_name_override)
{
compositor->display_name = _display_name_override;
if (wl_display_add_socket (compositor->wayland_display,
_display_name_override) != 0)
g_error ("Failed to create_socket");
g_clear_pointer (&_display_name_override, g_free);
}
else
{
compositor->display_name =
wl_display_add_socket_auto (compositor->wayland_display);
if (compositor->display_name == NULL)
g_error ("Failed to create socket");
}
set_gnome_env ("DISPLAY", meta_wayland_get_xwayland_display_name (compositor));
set_gnome_env ("WAYLAND_DISPLAY", meta_wayland_get_wayland_display_name (compositor));

View File

@ -27,6 +27,8 @@
#include <meta/types.h>
#include "meta-wayland-types.h"
void meta_wayland_override_display_name (char *display_name);
void meta_wayland_pre_clutter_init (void);
void meta_wayland_init (void);
void meta_wayland_finalize (void);