Bug 1677470 [Wayland] Enable to run Wayland on old Gtk for testing purposes but throw a warning message and add warning about GDK_BACKEND, r=jhorak
authorstransky <stransky@redhat.com>
Wed, 18 Nov 2020 13:33:27 +0000
changeset 557803 adab13d36ea3b6a6198436de9dba87b31aedbd22
parent 557802 46cf3717f89c04743b7c577ee3b0875185c0e95c
child 557804 556e3aff49e393fa73132271b8ce7196d1a59ab6
push id37962
push userapavel@mozilla.com
push dateWed, 18 Nov 2020 21:51:58 +0000
treeherdermozilla-central@9d797387f57c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak
bugs1677470
milestone85.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1677470 [Wayland] Enable to run Wayland on old Gtk for testing purposes but throw a warning message and add warning about GDK_BACKEND, r=jhorak Differential Revision: https://phabricator.services.mozilla.com/D97149
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -4066,28 +4066,32 @@ static void PR_CALLBACK ReadAheadDlls_Th
     // Load WinTypes.dll for nsOSHelperAppService::GetApplicationDescription
     ReadAheadSystemDll(L"WinTypes.dll");
   }
 }
 #endif
 
 #if defined(MOZ_WAYLAND)
 bool IsWaylandDisabled() {
-  const char* backendPref = PR_GetEnv("GDK_BACKEND");
-  if (backendPref && strcmp(backendPref, "wayland") == 0) {
-    return false;
-  }
-  // Enable Wayland on Gtk+ >= 3.22 where we can expect recent enough
-  // compositor & libwayland interface.
-  bool disableWayland = (gtk_check_version(3, 22, 0) != nullptr);
-  if (!disableWayland) {
-    // Make X11 backend the default one unless MOZ_ENABLE_WAYLAND is set.
-    disableWayland = (PR_GetEnv("MOZ_ENABLE_WAYLAND") == nullptr);
-  }
-  return disableWayland;
+  // MOZ_ENABLE_WAYLAND is our primary Wayland on/off switch.
+  const char* waylandPref = PR_GetEnv("MOZ_ENABLE_WAYLAND");
+  bool enableWayland = (waylandPref && *waylandPref);
+  if (!enableWayland) {
+    const char* backendPref = PR_GetEnv("GDK_BACKEND");
+    enableWayland = (backendPref && strncmp(backendPref, "wayland", 7) == 0);
+    if (enableWayland) {
+      NS_WARNING(
+          "Wayland backend should be enabled by MOZ_ENABLE_WAYLAND=1."
+          "GDK_BACKEND is a Gtk3 debug variable and may cause various issues.");
+    }
+  }
+  if (enableWayland && gtk_check_version(3, 22, 0) != nullptr) {
+    NS_WARNING("Running Wayland backen on Gtk3 < 3.22. Expect issues/glitches");
+  }
+  return !enableWayland;
 }
 #endif
 
 namespace mozilla::startup {
 Result<nsCOMPtr<nsIFile>, nsresult> GetIncompleteStartupFile(nsIFile* aProfLD) {
   nsCOMPtr<nsIFile> crashFile;
   MOZ_TRY(aProfLD->Clone(getter_AddRefs(crashFile)));
   MOZ_TRY(crashFile->Append(FILE_STARTUP_INCOMPLETE));