Bug 1426384 - Don't use CSD_SUPPORT_FULL on Wayland unless it's overriden by MOZ_GTK_TITLEBAR_DECORATION, r=jhorak
authorMartin Stransky <stransky@redhat.com>
Wed, 20 Dec 2017 16:32:51 +0100
changeset 448907 c0f87918768e1f058a8b49b6ac55166002738a20
parent 448906 b8a34037609130830a104c73c61a8722e4fb5bd1
child 448908 929eea667f6a18f525c64a4b3f92f288dc5869b4
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak
bugs1426384
milestone59.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 1426384 - Don't use CSD_SUPPORT_FULL on Wayland unless it's overriden by MOZ_GTK_TITLEBAR_DECORATION, r=jhorak Wayland compositors do not support GDK_DECOR_BORDER so use CSD decorations exclusively. MozReview-Commit-ID: 8gzDcw2AumI
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -7005,28 +7005,16 @@ nsWindow::DoDrawTitlebar() const
 }
 
 nsWindow::CSDSupportLevel
 nsWindow::GetCSDSupportLevel() {
     if (sCSDSupportLevel != CSD_SUPPORT_UNKNOWN) {
         return sCSDSupportLevel;
     }
 
-    const char* decorationOverride = getenv("MOZ_GTK_TITLEBAR_DECORATION");
-    if (decorationOverride) {
-        if (strcmp(decorationOverride, "none") == 0) {
-            sCSDSupportLevel = CSD_SUPPORT_NONE;
-        } else if (strcmp(decorationOverride, "client") == 0) {
-            sCSDSupportLevel = CSD_SUPPORT_FLAT;
-        } else if (strcmp(decorationOverride, "system") == 0) {
-            sCSDSupportLevel = CSD_SUPPORT_FULL;
-        }
-        return sCSDSupportLevel;
-    }
-
     const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
     if (currentDesktop) {
         if (strstr(currentDesktop, "GNOME") != nullptr) {
             sCSDSupportLevel = CSD_SUPPORT_FULL;
         } else if (strstr(currentDesktop, "XFCE") != nullptr) {
             sCSDSupportLevel = CSD_SUPPORT_FLAT;
         } else if (strstr(currentDesktop, "X-Cinnamon") != nullptr) {
             sCSDSupportLevel = CSD_SUPPORT_FULL;
@@ -7042,16 +7030,34 @@ nsWindow::GetCSDSupportLevel() {
             sCSDSupportLevel = CSD_SUPPORT_FLAT;
         } else {
             sCSDSupportLevel = CSD_SUPPORT_NONE;
         }
     } else {
         sCSDSupportLevel = CSD_SUPPORT_NONE;
     }
 
+    // We don't support CSD_SUPPORT_FULL on Wayland
+    if (!GDK_IS_X11_DISPLAY(gdk_display_get_default()) &&
+        sCSDSupportLevel == CSD_SUPPORT_FULL) {
+        sCSDSupportLevel = CSD_SUPPORT_FLAT;
+    }
+
+    // Allow MOZ_GTK_TITLEBAR_DECORATION to override our heuristics
+    const char* decorationOverride = getenv("MOZ_GTK_TITLEBAR_DECORATION");
+    if (decorationOverride) {
+        if (strcmp(decorationOverride, "none") == 0) {
+            sCSDSupportLevel = CSD_SUPPORT_NONE;
+        } else if (strcmp(decorationOverride, "client") == 0) {
+            sCSDSupportLevel = CSD_SUPPORT_FLAT;
+        } else if (strcmp(decorationOverride, "system") == 0) {
+            sCSDSupportLevel = CSD_SUPPORT_FULL;
+        }
+    }
+
     return sCSDSupportLevel;
 }
 
 int32_t
 nsWindow::RoundsWidgetCoordinatesTo()
 {
     return GdkScaleFactor();
 }