Bug 1743144 [Wayland] Enable Wayland proxy on start r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D196555
This commit is contained in:
stransky 2024-01-09 12:25:02 +00:00
parent ebb249d65e
commit e432414202

View File

@ -344,13 +344,24 @@ nsString gProcessStartupShortcut;
# ifdef MOZ_WAYLAND # ifdef MOZ_WAYLAND
# include <gdk/gdkwayland.h> # include <gdk/gdkwayland.h>
# include "mozilla/widget/nsWaylandDisplay.h" # include "mozilla/widget/nsWaylandDisplay.h"
# include "wayland-proxy.h"
# endif # endif
# ifdef MOZ_X11 # ifdef MOZ_X11
# include <gdk/gdkx.h> # include <gdk/gdkx.h>
# endif /* MOZ_X11 */ # endif /* MOZ_X11 */
#endif #endif
#if defined(MOZ_WAYLAND)
std::unique_ptr<WaylandProxy> gWaylandProxy;
#endif
#include "BinaryPath.h" #include "BinaryPath.h"
#ifdef MOZ_LOGGING
# include "mozilla/Logging.h"
extern mozilla::LazyLogModule gWidgetWaylandLog;
#endif /* MOZ_LOGGING */
#ifdef FUZZING #ifdef FUZZING
# include "FuzzerRunner.h" # include "FuzzerRunner.h"
@ -2791,6 +2802,9 @@ static ReturnAbortOnError ProfileLockedDialog(nsIFile* aProfileDir,
gRemoteService->UnlockStartup(); gRemoteService->UnlockStartup();
gRemoteService = nullptr; gRemoteService = nullptr;
} }
#endif
#if defined(MOZ_WAYLAND)
gWaylandProxy = nullptr;
#endif #endif
return LaunchChild(false, true); return LaunchChild(false, true);
} }
@ -2905,6 +2919,9 @@ static ReturnAbortOnError ShowProfileManager(
gRemoteService->UnlockStartup(); gRemoteService->UnlockStartup();
gRemoteService = nullptr; gRemoteService = nullptr;
} }
#endif
#if defined(MOZ_WAYLAND)
gWaylandProxy = nullptr;
#endif #endif
return LaunchChild(false, true); return LaunchChild(false, true);
} }
@ -4711,6 +4728,23 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
const char* display_name = nullptr; const char* display_name = nullptr;
bool saveDisplayArg = false; bool saveDisplayArg = false;
bool waylandEnabled = IsWaylandEnabled();
# ifdef MOZ_WAYLAND
auto* proxyEnv = getenv("MOZ_DISABLE_WAYLAND_PROXY");
bool disableWaylandProxy = proxyEnv && *proxyEnv;
if (!disableWaylandProxy && XRE_IsParentProcess() && waylandEnabled) {
# ifdef MOZ_LOGGING
if (MOZ_LOG_TEST(gWidgetWaylandLog, mozilla::LogLevel::Debug)) {
WaylandProxy::SetVerbose(true);
}
# endif
gWaylandProxy = WaylandProxy::Create();
if (gWaylandProxy) {
gWaylandProxy->RunThread();
}
}
# endif
// display_name is owned by gdk. // display_name is owned by gdk.
display_name = gdk_get_display_arg_name(); display_name = gdk_get_display_arg_name();
// if --display argument is given make sure it's // if --display argument is given make sure it's
@ -4720,7 +4754,6 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
saveDisplayArg = true; saveDisplayArg = true;
} }
bool waylandEnabled = IsWaylandEnabled();
// On Wayland disabled builds read X11 DISPLAY env exclusively // On Wayland disabled builds read X11 DISPLAY env exclusively
// and don't care about different displays. // and don't care about different displays.
if (!waylandEnabled && !display_name) { if (!waylandEnabled && !display_name) {
@ -5959,6 +5992,7 @@ int XREMain::XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig) {
if (!gfxPlatform::IsHeadless()) { if (!gfxPlatform::IsHeadless()) {
# ifdef MOZ_WAYLAND # ifdef MOZ_WAYLAND
WaylandDisplayRelease(); WaylandDisplayRelease();
gWaylandProxy = nullptr;
# endif # endif
} }
#endif #endif