Blob Blame History Raw
diff -up thunderbird-60.5.0/toolkit/xre/nsAppRunner.cpp.1522780 thunderbird-60.5.0/toolkit/xre/nsAppRunner.cpp
--- thunderbird-60.5.0/toolkit/xre/nsAppRunner.cpp.1522780	2019-02-05 20:57:28.384820067 +0100
+++ thunderbird-60.5.0/toolkit/xre/nsAppRunner.cpp	2019-02-05 21:05:27.623511428 +0100
@@ -3872,10 +3872,26 @@ int XREMain::XRE_mainStartup(bool* aExit
       saveDisplayArg = true;
     }
 
-      // On Wayland disabled builds read X11 DISPLAY env exclusively
-      // and don't care about different displays.
-#if !defined(MOZ_WAYLAND)
-    if (!display_name) {
+    bool disableWayland = true;
+#if defined(MOZ_WAYLAND)
+    // Make X11 backend the default one.
+    // Enable Wayland backend only when GDK_BACKEND is set and
+    // Gtk+ >= 3.22 where we can expect recent enough
+    // compositor & libwayland interface.
+    disableWayland = (PR_GetEnv("GDK_BACKEND") == nullptr) ||
+                     (gtk_check_version(3, 22, 0) != nullptr);
+    // Enable Wayland on Gtk+ >= 3.22 where we can expect recent enough
+    disableWayland = (gtk_check_version(3, 22, 0) != nullptr);
+    if (!disableWayland) {
+      // Make X11 backend the default one unless MOZ_ENABLE_WAYLAND or
+      // GDK_BACKEND are specified.
+      disableWayland = (PR_GetEnv("GDK_BACKEND") == nullptr) &&
+                       (PR_GetEnv("MOZ_ENABLE_WAYLAND") == nullptr);
+    }
+#endif
+    // On Wayland disabled builds read X11 DISPLAY env exclusively
+    // and don't care about different displays.
+    if (disableWayland && !display_name) {
       display_name = PR_GetEnv("DISPLAY");
       if (!display_name) {
         PR_fprintf(PR_STDERR,
@@ -3883,7 +3899,6 @@ int XREMain::XRE_mainStartup(bool* aExit
         return 1;
       }
     }
-#endif
 
     if (display_name) {
       mGdkDisplay = gdk_display_open(display_name);