Bug 1882255 [Linux] Quit early if there isn't any display connection and we need it r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D202807
This commit is contained in:
stransky 2024-02-29 21:07:05 +00:00
parent 7fd26424b8
commit 59f283c3cc

View file

@ -4747,31 +4747,13 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
if (saveDisplayArg) {
if (GdkIsX11Display(disp)) {
SaveWordToEnv("DISPLAY", nsDependentCString(display_name));
}
# ifdef MOZ_WAYLAND
else if (GdkIsWaylandDisplay(disp)) {
} else if (GdkIsWaylandDisplay(disp)) {
SaveWordToEnv("WAYLAND_DISPLAY", nsDependentCString(display_name));
}
# endif
}
}
# ifdef MOZ_WIDGET_GTK
else {
} else {
gdk_display_manager_open_display(gdk_display_manager_get(), nullptr);
}
# endif
// Check that Wayland only and X11 only builds
// use appropriate displays.
# if defined(MOZ_WAYLAND) && !defined(MOZ_X11)
if (!GdkIsWaylandDisplay()) {
Output(true, "Wayland only build is missig Wayland display!\n");
}
# endif
# if !defined(MOZ_WAYLAND) && defined(MOZ_X11)
if (!GdkIsX11Display()) {
Output(true, "X11 only build is missig X11 display!\n");
}
# endif
# if defined(MOZ_WAYLAND)
// We want to use proxy for main connection only so
// restore original Wayland display for next potential Wayland connections
@ -4779,6 +4761,27 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
if (gWaylandProxy) {
gWaylandProxy->RestoreWaylandDisplay();
}
# endif
if (!gdk_display_get_default()) {
Output(true,
"Error: we don't have any display, WAYLAND_DISPLAY='%s' "
"DISPLAY='%s'\n",
PR_GetEnv("WAYLAND_DISPLAY"), PR_GetEnv("DISPLAY"));
return 1;
}
// Check that Wayland only and X11 only builds
// use appropriate displays.
# if defined(MOZ_WAYLAND) && !defined(MOZ_X11)
if (!GdkIsWaylandDisplay()) {
Output(true, "Wayland only build is missig Wayland display!\n");
return 1;
}
# endif
# if !defined(MOZ_WAYLAND) && defined(MOZ_X11)
if (!GdkIsX11Display()) {
Output(true, "X11 only build is missig X11 display!\n");
return 1;
}
# endif
}
#endif