tests: Override X11 display number

As with the Wayland display name, to avoid clashes with already an
running Xwayland or Xorg instance, override the X11 display name to
something less likely to cause a clash.

https://gitlab.gnome.org/GNOME/mutter/issues/193
This commit is contained in:
Jonas Ådahl 2018-11-12 11:29:44 +01:00
parent fe1d9fb4a7
commit bd624e4dfb
3 changed files with 16 additions and 5 deletions

View File

@ -27,6 +27,7 @@
#include "core/display-private.h"
#include "core/window-private.h"
#include "wayland/meta-wayland.h"
#include "wayland/meta-xwayland.h"
#include "x11/meta-x11-display-private.h"
struct _TestClient {
@ -94,6 +95,7 @@ test_init (int *argc,
ensure_test_client_path (*argc, *argv);
meta_wayland_override_display_name ("mutter-test-display");
meta_xwayland_override_display_number (512);
}
AsyncWaiter *

View File

@ -59,6 +59,8 @@ G_DEFINE_TYPE (MetaWaylandSurfaceRoleXWayland,
meta_wayland_surface_role_xwayland,
META_TYPE_WAYLAND_ACTOR_SURFACE)
static int display_number_override = -1;
void
meta_xwayland_associate_window_with_surface (MetaWindow *window,
MetaWaylandSurface *surface)
@ -371,6 +373,12 @@ x_io_error (Display *display)
return 0;
}
void
meta_xwayland_override_display_number (int number)
{
display_number_override = number;
}
static gboolean
choose_xdisplay (MetaXWaylandManager *manager)
{
@ -378,11 +386,9 @@ choose_xdisplay (MetaXWaylandManager *manager)
char *lock_file = NULL;
gboolean fatal = FALSE;
/* Hack to keep the unused Xwayland instance on
* the login screen from taking the prime :0 display
* number.
*/
if (g_getenv ("RUNNING_UNDER_GDM") != NULL)
if (display_number_override != -1)
display = display_number_override;
else if (!g_getenv ("RUNNING_UNDER_GDM"))
display = 1024;
do

View File

@ -30,6 +30,9 @@
#include "meta/types.h"
#include "wayland/meta-wayland-types.h"
void
meta_xwayland_override_display_number (int number);
void
meta_xwayland_handle_wl_surface_id (MetaWindow *window,
guint32 surface_id);