firefox/D196555.diff
2024-01-02 15:22:55 +01:00

112 lines
3.1 KiB
Diff

diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -342,17 +342,28 @@
# include "mozilla/WidgetUtilsGtk.h"
# include <gtk/gtk.h>
# ifdef MOZ_WAYLAND
# include <gdk/gdkwayland.h>
# include "mozilla/widget/nsWaylandDisplay.h"
+# include "wayland-proxy.h"
# endif
# ifdef MOZ_X11
# include <gdk/gdkx.h>
# endif /* MOZ_X11 */
#endif
+
+#if defined(MOZ_WAYLAND)
+std::unique_ptr<WaylandProxy> gWaylandProxy;
+#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;
@@ -2790,10 +2801,13 @@
if (gRemoteService) {
gRemoteService->UnlockStartup();
gRemoteService = nullptr;
}
#endif
+#if defined(MOZ_WAYLAND)
+ gWaylandProxy = nullptr;
+#endif
return LaunchChild(false, true);
}
} else {
rv = ps->Alert(nullptr, killTitle.get(), killMessage.get());
NS_ENSURE_SUCCESS_LOG(rv, rv);
@@ -2904,10 +2918,13 @@
if (gRemoteService) {
gRemoteService->UnlockStartup();
gRemoteService = nullptr;
}
#endif
+#if defined(MOZ_WAYLAND)
+ gWaylandProxy = nullptr;
+#endif
return LaunchChild(false, true);
}
static bool gDoMigration = false;
static bool gDoProfileReset = false;
@@ -4709,20 +4726,36 @@
#if defined(MOZ_WIDGET_GTK)
if (!isBackgroundTaskMode && !gfxPlatform::IsHeadless()) {
const char* display_name = nullptr;
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 = 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) {
@@ -5952,10 +5985,11 @@
// gdk_display_close also calls gdk_display_manager_set_default_display
// appropriately when necessary.
if (!gfxPlatform::IsHeadless()) {
# ifdef MOZ_WAYLAND
WaylandDisplayRelease();
+ gWaylandProxy = nullptr;
# endif
}
#endif
XRE_DeinitCommandLine();