Bug 1409716 - Don't use DetectDisplay() for child process, r?glandium draft
authorMartin Stransky <stransky@redhat.com>
Wed, 25 Oct 2017 14:53:15 +0200
changeset 689207 706534a375aa139f69fbd6e138bef42d3703da79
parent 686086 4708a6b3e4840ce2b3979bee29066859a75eab6d
child 738271 dc0d7691d0aa4265a7a1d18a2dbe5e868e4204ed
push id86970
push userstransky@redhat.com
push dateTue, 31 Oct 2017 09:04:16 +0000
reviewersglandium
bugs1409716
milestone58.0a1
Bug 1409716 - Don't use DetectDisplay() for child process, r?glandium Don't retrieve parent display by DetectDisplay(). Utilize MOZ_GDK_DISPLAY when available, when it's missing query DISPLAY env variable for X11 only builds and standard gtk_init() for Wayland enabled builds. MozReview-Commit-ID: 9yebsISeNjc
dom/ipc/ContentChild.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -565,23 +565,31 @@ ContentChild::RecvSetXPCOMProcessAttribu
 bool
 ContentChild::Init(MessageLoop* aIOLoop,
                    base::ProcessId aParentPid,
                    IPC::Channel* aChannel,
                    uint64_t aChildID,
                    bool aIsForBrowser)
 {
 #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.
+  // When running X11 only build 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.
+  // The MOZ_GDK_DISPLAY environment variable is set from nsAppRunner.cpp
+  // when --display is set by the command line.
   if (!gfxPlatform::IsHeadless()) {
-    const char* display_name = DetectDisplay();
+    const char* display_name = PR_GetEnv("MOZ_GDK_DISPLAY");
+#ifndef MOZ_WAYLAND
+    if (!display_name) {
+      display_name = PR_GetEnv("DISPLAY");
+    }
+#endif
     if (display_name) {
       int argc = 3;
       char option_name[] = "--display";
       char* argv[] = {
         // argv0 is unused because g_set_prgname() was called in
         // XRE_InitChildProcess().
         nullptr,
         option_name,