Bug 1234026 - Pass a --display option to gtk_init in content processes. r=karlt, a=sledru
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 23 Dec 2015 12:11:45 +0900
changeset 310788 69c01f698fd008e5af45d49ecfcbe2accc3af2f9
parent 310787 e4e34060f38271a3c47d5b49b29ac437fb8e0ad6
child 310789 bedac201438fbe8b904e8f3d7767c6f0c2731010
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt, sledru
bugs1234026
milestone45.0a2
Bug 1234026 - Pass a --display option to gtk_init in content processes. r=karlt, a=sledru
dom/ipc/ContentChild.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -615,17 +615,36 @@ NS_INTERFACE_MAP_BEGIN(ContentChild)
 NS_INTERFACE_MAP_END
 
 bool
 ContentChild::Init(MessageLoop* aIOLoop,
                    base::ProcessId aParentPid,
                    IPC::Channel* aChannel)
 {
 #ifdef MOZ_WIDGET_GTK
+  // 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
     // sigh, seriously
     nsQAppInstance::AddRef();
 #endif
 
 #ifdef MOZ_X11