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
--- 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,