Bug 1663279 [Linux] Update default titlebar configration, r=jhorak
authorstransky <stransky@redhat.com>
Mon, 07 Sep 2020 11:54:51 +0000
changeset 547730 c500459f5539756b3972d6ab0a0ee7346e328093
parent 547729 5ac011c643ed81fb74982843660d1a8bf6d4b035
child 547731 614b02845d8907a46e00d46cbe7e0ac6d3e6d1ee
push id37761
push userrmaries@mozilla.com
push dateMon, 07 Sep 2020 15:34:13 +0000
treeherdermozilla-central@c500459f5539 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak
bugs1663279
milestone82.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 1663279 [Linux] Update default titlebar configration, r=jhorak - Use toplevel transparent window by default. - Use Client decoration for Deepin desktop. - Hide system titlebar by default on latest KDE versions. - Hide system titlebar by default on Gnome/Pantheon. Differential Revision: https://phabricator.services.mozilla.com/D89363
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -4162,17 +4162,17 @@ bool nsWindow::IsMainWindowTransparent()
       // It may cause performanance issue so make it configurable
       // and enable it by default for selected window managers.
       if (Preferences::HasUserValue("mozilla.widget.use-argb-visuals")) {
         // argb visual is explicitly required so use it
         sTransparentMainWindow =
             Preferences::GetBool("mozilla.widget.use-argb-visuals");
       } else {
         sTransparentMainWindow =
-            (gfxPlatformGtk::GetPlatform()->IsWaylandDisplay() &&
+            (gfxPlatformGtk::GetPlatform()->IsWaylandDisplay() ||
              GetSystemCSDSupportLevel() != CSD_SUPPORT_NONE);
       }
     }
     transparencyConfigured = true;
   }
 
   return sTransparentMainWindow;
 }
@@ -7776,17 +7776,17 @@ nsWindow::CSDSupportLevel nsWindow::GetS
     } else if (strstr(currentDesktop, "Unity") != nullptr) {
       sCSDSupportLevel = CSD_SUPPORT_SYSTEM;
       // Elementary OS
     } else if (strstr(currentDesktop, "Pantheon") != nullptr) {
       sCSDSupportLevel = CSD_SUPPORT_SYSTEM;
     } else if (strstr(currentDesktop, "LXQt") != nullptr) {
       sCSDSupportLevel = CSD_SUPPORT_SYSTEM;
     } else if (strstr(currentDesktop, "Deepin") != nullptr) {
-      sCSDSupportLevel = CSD_SUPPORT_SYSTEM;
+      sCSDSupportLevel = CSD_SUPPORT_CLIENT;
     } else {
 // Release or beta builds are not supposed to be broken
 // so disable titlebar rendering on untested/unknown systems.
 #if defined(RELEASE_OR_BETA)
       sCSDSupportLevel = CSD_SUPPORT_NONE;
 #else
       sCSDSupportLevel = CSD_SUPPORT_CLIENT;
 #endif
@@ -7841,25 +7841,47 @@ bool nsWindow::HideTitlebarByDefault() {
   // When user defined widget.default-hidden-titlebar don't do any
   // heuristics and just follow it.
   if (Preferences::HasUserValue("widget.default-hidden-titlebar")) {
     hideTitlebar =
         Preferences::GetBool("widget.default-hidden-titlebar", false);
     return hideTitlebar;
   }
 
+  // We want to hide the system titlebar by default.
+  hideTitlebar = true;
+
+  // Don't hide titlebar when we can't draw round corners.
+  GdkScreen* screen = gdk_screen_get_default();
+  if (!gdk_screen_is_composited(screen) && !TitlebarCanUseShapeMask()) {
+    hideTitlebar = false;
+    return hideTitlebar;
+  }
+  // Don't hide titlebar when it's disabled on current desktop.
   const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
-  hideTitlebar =
-      (currentDesktop && GetSystemCSDSupportLevel() != CSD_SUPPORT_NONE);
-
-  GdkScreen* screen;
-  hideTitlebar = ((screen = gdk_screen_get_default()) &&
-                  gdk_screen_is_composited(screen)) ||
-                 TitlebarCanUseShapeMask();
-
+  if (!currentDesktop || GetSystemCSDSupportLevel() == CSD_SUPPORT_NONE) {
+    hideTitlebar = false;
+    return hideTitlebar;
+  }
+
+  // We hide system titlebar on Gnome/ElementaryOS without any restriction.
+  if ((strstr(currentDesktop, "GNOME-Flashback:GNOME") != nullptr ||
+       strstr(currentDesktop, "GNOME") != nullptr ||
+       strstr(currentDesktop, "Pantheon") != nullptr)) {
+    return hideTitlebar;
+  }
+
+  // We hide system titlebar on KDE on recent enough systems.
+  if (gtk_check_version(3, 24, 0) == nullptr &&
+      strstr(currentDesktop, "KDE") != nullptr) {
+    return hideTitlebar;
+  }
+
+  // Don't hide system titlebar by default for other desktops.
+  hideTitlebar = false;
   return hideTitlebar;
 }
 
 int32_t nsWindow::RoundsWidgetCoordinatesTo() { return GdkScaleFactor(); }
 
 void nsWindow::GetCompositorWidgetInitData(
     mozilla::widget::CompositorWidgetInitData* aInitData) {
   // Make sure the window XID is propagated to X server, we can fail otherwise