Bug 1336048 - Add display detection to dom/ipc/ContentChild.cpp, r=glandium
authorMartin Stransky <stransky@redhat.com>
Tue, 07 Feb 2017 14:34:23 +0100
changeset 387778 8d482c6c4efb5264c7300eb352bb23a1530b49fb
parent 387777 4f2f1e1c6362bd5b8a2d273662b4ad4414d8f320
child 387779 ef2825d0cbfa36f2a2fe1e2bea8717bd2ffd2581
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1336048
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1336048 - Add display detection to dom/ipc/ContentChild.cpp, r=glandium MozReview-Commit-ID: CwcGXFiIl4e
dom/ipc/ContentChild.cpp
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsAppRunner.h
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -196,16 +196,21 @@
 #include "mozilla/widget/PuppetBidiKeyboard.h"
 #include "mozilla/RemoteSpellCheckEngineChild.h"
 #include "GMPServiceChild.h"
 #include "GfxInfoBase.h"
 #include "gfxPlatform.h"
 #include "nscore.h" // for NS_FREE_PERMANENT_DATA
 #include "VRManagerChild.h"
 
+#ifdef MOZ_WIDGET_GTK
+#include "nsAppRunner.h"
+#endif
+
+
 using namespace mozilla;
 using namespace mozilla::docshell;
 using namespace mozilla::dom::devicestorage;
 using namespace mozilla::dom::ipc;
 using namespace mozilla::dom::workers;
 using namespace mozilla::media;
 using namespace mozilla::embedding;
 using namespace mozilla::gmp;
@@ -522,26 +527,26 @@ ContentChild::Init(MessageLoop* aIOLoop,
                    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.
   // The DISPLAY environment variable is normally set by the parent process.
-  char* display_name = PR_GetEnv("DISPLAY");
+  const char* display_name = DetectDisplay();
   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,
-      display_name,
+      const_cast<char*>(display_name),
       nullptr
     };
     char** argvp = argv;
     gtk_init(&argc, &argvp);
   } else {
     gtk_init(nullptr, nullptr);
   }
 #endif
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2887,17 +2887,17 @@ static void MOZ_gdk_display_close(GdkDis
   }
 #else // not CLEANUP_MEMORY
   // Don't do anything to avoid running into driver bugs under XCloseDisplay().
   // See bug 973192.
   (void) display;
 #endif
 }
 
-static const char* detectDisplay(void)
+const char* DetectDisplay(void)
 {
   bool tryX11 = false;
   bool tryWayland = false;
   bool tryBroadway = false;
 
   // Honor user backend selection
   const char *backend = PR_GetEnv("GDK_BACKEND");
   if (!backend || strstr(backend, "*")) {
@@ -3745,17 +3745,17 @@ XREMain::XRE_mainStartup(bool* aExitFlag
 
 #if defined(MOZ_WIDGET_GTK)
   // display_name is owned by gdk.
   const char *display_name = gdk_get_display_arg_name();
   bool saveDisplayArg = false;
   if (display_name) {
     saveDisplayArg = true;
   } else {
-    display_name = detectDisplay();
+    display_name = DetectDisplay();
     if (!display_name) {
       return 1;
     }
   }
 #endif /* MOZ_WIDGET_GTK */
 #ifdef MOZ_X11
   // Init X11 in thread-safe mode. Must be called prior to the first call to XOpenDisplay
   // (called inside gdk_display_open). This is a requirement for off main tread compositing.
--- a/toolkit/xre/nsAppRunner.h
+++ b/toolkit/xre/nsAppRunner.h
@@ -128,9 +128,13 @@ void SetupErrorHandling(const char* prog
 
 /**
  * A numeric value indicating whether multiprocess might be blocked.
  * Possible values can be found at nsAppRunner.cpp. A value of 0
  * represents not blocking.
  */
 uint32_t MultiprocessBlockPolicy();
 
+#ifdef MOZ_WIDGET_GTK
+const char* DetectDisplay();
+#endif
+
 #endif // nsAppRunner_h__