Bug 1336048 - Add display detection to dom/ipc/ContentChild.cpp, r?glandium
MozReview-Commit-ID: CwcGXFiIl4e
--- 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;
@@ -508,26 +513,26 @@ ContentChild::Init(MessageLoop* aIOLoop,
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");
+ 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__