From 9d12d36bfb7d9b675247e5c2d1f6c75878510e65 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 23 Dec 2015 12:11:45 +0900 Subject: [PATCH] Bug 1234026 - Pass a --display option to gtk_init in content processes. r=karlt --- dom/ipc/ContentChild.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 46ad9150152..f3d88a6082e 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -618,7 +618,26 @@ ContentChild::Init(MessageLoop* aIOLoop, IPC::Channel* aChannel) { #ifdef MOZ_WIDGET_GTK - gtk_init(nullptr, nullptr); + // We need to pass a display down to gtk_init because it's not going to + // use the one from the environment on its own when deciding which backend + // to use, and when starting under XWayland, it may choose to start with + // the wayland backend instead of the x11 backend. + // The DISPLAY environment variable is normally set by the parent process. + char* display_name = PR_GetEnv("DISPLAY"); + if (display_name) { + int argc = 3; + char option_name[] = "--display"; + char* argv[] = { + nullptr, + option_name, + display_name, + nullptr + }; + char** argvp = argv; + gtk_init(&argc, &argvp); + } else { + gtk_init(nullptr, nullptr); + } #endif #ifdef MOZ_WIDGET_QT