Bug 1418005 - Draw CSD titlebar according to -moz-gtk-csd-available and draw tilebar buttons. r=aceman
authorRichard Marti <richard.marti@gmail.com>
Fri, 17 Nov 2017 23:42:40 +0100
changeset 28156 4816ac3cb5bcb4c5f313c090b87495bc08282787
parent 28155 09e954abfc4a5bff50244c043d77448dfb35769a
child 28157 d342491c066b3641a046d7249a98cb01da05d8fb
push idunknown
push userunknown
push dateunknown
reviewersaceman
bugs1418005
Bug 1418005 - Draw CSD titlebar according to -moz-gtk-csd-available and draw tilebar buttons. r=aceman
mail/app/profile/all-thunderbird.js
mail/base/moz.build
mail/themes/linux/mail/messenger.css
mail/themes/linux/mail/tabmail.css
--- a/mail/app/profile/all-thunderbird.js
+++ b/mail/app/profile/all-thunderbird.js
@@ -492,21 +492,17 @@ pref("mail.tabs.closeWindowWithLastTab",
 // Where to show tab close buttons:
 // 0 - active tab only
 // 1 - all tabs until tabClipWidth is reached, then active tab only
 // 2 - no close buttons
 // 3 - at the end of the tabstrip
 pref("mail.tabs.closeButtons", 1);
 
 // Allow the tabs to be in the titlebar on supported systems
-#ifdef UNIX_BUT_NOT_MAC
-pref("mail.tabs.drawInTitlebar", false);
-#else
 pref("mail.tabs.drawInTitlebar", true);
-#endif
 
 // The breakpad report server to link to in about:crashes
 pref("breakpad.reportURL", "https://crash-stats.mozilla.com/report/index/");
 
 // OS Integrated Search and Indexing
 #ifdef XP_WIN
 pref("mail.winsearch.enable", false);
 pref("mail.winsearch.firstRunDone", false);
--- a/mail/base/moz.build
+++ b/mail/base/moz.build
@@ -16,15 +16,15 @@ DEFINES['mozreltopsrcdir'] = CONFIG['moz
 DEFINES['APP_LICENSE_BLOCK'] = '%s/content/overrides/app-license.html' % SRCDIR
 
 if CONFIG['MOZILLA_OFFICIAL']:
     DEFINES['OFFICIAL_BUILD'] = 1
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3', 'cocoa'):
     DEFINES['HAVE_SHELL_SERVICE'] = 1
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'cocoa'):
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'cocoa', 'gtk3'):
     DEFINES['CAN_DRAW_IN_TITLEBAR'] = 1
 
 if CONFIG['MOZ_UPDATER']:
     DEFINES['MOZ_UPDATER'] = 1
 
 DEFINES['TOOLKIT_DIR'] = "%s/toolkit" % (CONFIG['moztopsrcdir'],)
--- a/mail/themes/linux/mail/messenger.css
+++ b/mail/themes/linux/mail/messenger.css
@@ -83,16 +83,98 @@ toolbar[brighttext] {
 
   --toolbarbutton-active-background: rgba(70%, 70%, 70%, .25);
   --toolbarbutton-active-bordercolor: rgba(0, 0, 0, .3);
   --toolbarbutton-active-boxshadow: 0 0 2px rgba(0, 0, 0, .6) inset;
 
   --toolbarbutton-checkedhover-backgroundcolor: rgba(85%, 85%, 85%, .25);
 }
 
+/* Hide the titlebar explicitly on versions of GTK+ where
+ * it's rendered by window manager. */
+@media (-moz-gtk-csd-available: 0) {
+  #titlebar {
+    display: none;
+  }
+}
+
+/* We draw to titlebar when Gkt+ CSD is available */
+@media (-moz-gtk-csd-available) {
+  :root[tabsintitlebar] > #titlebar:-moz-lwtheme {
+    visibility: hidden;
+  }
+  :root[tabsintitlebar] > #titlebar-content:-moz-lwtheme {
+    visibility: visible;
+  }
+
+  :root[tabsintitlebar][sizemode="normal"] > #titlebar {
+    -moz-appearance: -moz-window-titlebar;
+  }
+  :root[tabsintitlebar][sizemode="maximized"] > #titlebar {
+    -moz-appearance: -moz-window-titlebar-maximized;
+  }
+
+  /* The button box must appear on top of the navigator-toolbox in order for
+   * click and hover mouse events to work properly for the button in the restored
+   * window state. Otherwise, elements in the navigator-toolbox, like the menubar,
+   * can swallow those events.
+   */
+  #titlebar-buttonbox {
+    position: relative;
+    z-index: 1;
+  }
+
+  .titlebar-button {
+    padding: initial;
+  }
+
+  /* Render titlebar command buttons according to system config.
+   * Use full scale icons here as the Gtk+ does.
+   */
+  @media (-moz-gtk-csd-minimize-button) {
+    #titlebar-min {
+      list-style-image: url("moz-icon://stock/window-minimize-symbolic");
+      -moz-appearance: -moz-window-button-minimize;
+    }
+  }
+  @media (-moz-gtk-csd-minimize-button: 0) {
+    #titlebar-min {
+      display: none;
+    }
+  }
+
+  @media (-moz-gtk-csd-maximize-button) {
+    #titlebar-max {
+      list-style-image: url("moz-icon://stock/window-maximize-symbolic");
+      -moz-appearance: -moz-window-button-maximize;
+    }
+    :root[sizemode="maximized"] #titlebar-max {
+      list-style-image: url("moz-icon://stock/window-restore-symbolic");
+      -moz-appearance: -moz-window-button-restore;
+    }
+  }
+  @media (-moz-gtk-csd-maximize-button: 0) {
+    #titlebar-max {
+      display: none;
+    }
+  }
+
+  @media (-moz-gtk-csd-close-button) {
+    #titlebar-close {
+      list-style-image: url("moz-icon://stock/window-close-symbolic");
+      -moz-appearance: -moz-window-button-close;
+    }
+  }
+  @media (-moz-gtk-csd-close-button: 0) {
+    #titlebar-close {
+      display: none;
+    }
+  }
+}
+
 toolbar:not(.inline-toolbar):not(:-moz-lwtheme) {
   -moz-appearance: menubar;
   color: -moz-menubartext;
 }
 
 /*
  * Override the menulist icon forbidding in menu.css so that we can show
  * check-marks. radio-marks and folder icons. bug 443516
--- a/mail/themes/linux/mail/tabmail.css
+++ b/mail/themes/linux/mail/tabmail.css
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 @import url("chrome://messenger/skin/shared/tabmail.css");
 
 /**
  * Tabmail Tabs
  */
 
-#navigation-toolbox:not(:-moz-lwtheme) {
+:root:not([tabsintitlebar]) > #navigation-toolbox:not(:-moz-lwtheme) {
   -moz-appearance: menubar;
 }
 
 #tabs-toolbar {
   -moz-appearance: none;
   padding: 0;
 }