firefox/D196555.diff
2023-12-19 09:56:23 +01:00

110 lines
3.0 KiB
Diff

diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -343,16 +343,24 @@
# include <gtk/gtk.h>
# ifdef MOZ_WAYLAND
# include <gdk/gdkwayland.h>
# include "mozilla/widget/nsWaylandDisplay.h"
# endif
+# ifdef MOZ_WAYLAND_PROXY
+# include "wayland-proxy.h"
+# endif
# ifdef MOZ_X11
# include <gdk/gdkx.h>
# endif /* MOZ_X11 */
#endif
#include "BinaryPath.h"
+#ifdef MOZ_LOGGING
+# include "mozilla/Logging.h"
+extern mozilla::LazyLogModule gWidgetWaylandLog;
+#endif /* MOZ_LOGGING */
+
#ifdef FUZZING
# include "FuzzerRunner.h"
namespace mozilla {
FuzzerRunner* fuzzerRunner = 0;
@@ -3670,10 +3678,13 @@
class XREMain {
public:
XREMain() = default;
~XREMain() {
+#if defined(MOZ_WAYLAND_PROXY)
+ mWaylandProxy = nullptr;
+#endif
mScopedXPCOM = nullptr;
mAppData = nullptr;
}
int XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig);
@@ -3689,10 +3700,13 @@
nsCOMPtr<nsIFile> mProfLD;
nsCOMPtr<nsIProfileLock> mProfileLock;
#if defined(MOZ_HAS_REMOTE)
RefPtr<nsRemoteService> mRemoteService;
#endif
+#if defined(MOZ_WAYLAND_PROXY)
+ std::unique_ptr<WaylandProxy> mWaylandProxy;
+#endif
UniquePtr<ScopedXPCOMStartup> mScopedXPCOM;
UniquePtr<XREAppData> mAppData;
nsXREDirProvider mDirProvider;
@@ -4709,20 +4723,34 @@
#if defined(MOZ_WIDGET_GTK)
if (!isBackgroundTaskMode && !gfxPlatform::IsHeadless()) {
const char* display_name = nullptr;
bool saveDisplayArg = false;
+ bool waylandEnabled = IsWaylandEnabled();
+# ifdef MOZ_WAYLAND_PROXY
+ auto* proxyEnv = getenv("MOZ_DISABLE_WAYLAND_PROXY");
+ bool disableWaylandProxy = proxyEnv && *proxyEnv;
+ if (!disableWaylandProxy && XRE_IsParentProcess() && waylandEnabled) {
+ mWaylandProxy = WaylandProxy::Create();
+ mWaylandProxy->RunThread();
+# ifdef MOZ_LOGGING
+ if (MOZ_LOG_TEST(gWidgetWaylandLog, mozilla::LogLevel::Debug)) {
+ mWaylandProxy->SetVerbose(true);
+ }
+# endif
+ }
+# endif
+
// display_name is owned by gdk.
display_name = gdk_get_display_arg_name();
// if --display argument is given make sure it's
// also passed to ContentChild::Init() by MOZ_GDK_DISPLAY.
if (display_name) {
SaveWordToEnv("MOZ_GDK_DISPLAY", nsDependentCString(display_name));
saveDisplayArg = true;
}
- bool waylandEnabled = IsWaylandEnabled();
// On Wayland disabled builds read X11 DISPLAY env exclusively
// and don't care about different displays.
if (!waylandEnabled && !display_name) {
display_name = PR_GetEnv("DISPLAY");
if (!display_name) {
@@ -5953,10 +5981,15 @@
// appropriately when necessary.
if (!gfxPlatform::IsHeadless()) {
# ifdef MOZ_WAYLAND
WaylandDisplayRelease();
# endif
+# ifdef MOZ_WAYLAND_PROXY
+ if (mWaylandProxy) {
+ mWaylandProxy = nullptr;
+ }
+# endif
}
#endif
XRE_DeinitCommandLine();