diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index a9e1e937aae4..cc1d9701c633 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -629,11 +629,6 @@ pref("browser.tabs.tabMinWidth", 76); // secondary text on tabs hidden due to size constraints and readability // of the text at small font sizes. pref("browser.tabs.secondaryTextUnsupportedLocales", "ar,bn,bo,ckb,fa,gu,he,hi,ja,km,kn,ko,lo,mr,my,ne,pa,si,ta,te,th,ur,zh"); -// Initial titlebar state is managed by -moz-gtk-csd-hide-titlebar-by-default -// on Linux. -#ifndef UNIX_BUT_NOT_MAC - pref("browser.tabs.drawInTitlebar", true); -#endif //Control the visibility of Tab Manager Menu. pref("browser.tabs.tabmanager.enabled", false); diff --git a/browser/base/content/browser-tabsintitlebar.js b/browser/base/content/browser-tabsintitlebar.js index 23301332d842..cf11dbdbe9fd 100644 --- a/browser/base/content/browser-tabsintitlebar.js +++ b/browser/base/content/browser-tabsintitlebar.js @@ -54,10 +54,7 @@ var TabsInTitlebar = { _prefName: "browser.tabs.drawInTitlebar", _readPref() { - let hiddenTitlebar = Services.prefs.getBoolPref( - "browser.tabs.drawInTitlebar", - window.matchMedia("(-moz-gtk-csd-hide-titlebar-by-default)").matches - ); + let hiddenTitlebar = Services.appinfo.drawInTitlebar; this.allowedBy("pref", hiddenTitlebar); }, diff --git a/browser/base/content/test/popups/browser_popupUI.js b/browser/base/content/test/popups/browser_popupUI.js index 6b65cee57a27..237636b13cc4 100644 --- a/browser/base/content/test/popups/browser_popupUI.js +++ b/browser/base/content/test/popups/browser_popupUI.js @@ -61,8 +61,8 @@ add_task(async function titlebar_buttons_visibility() { Services.prefs.setIntPref("browser.link.open_newwindow", 2); const drawInTitlebarValues = [ - [true, BUTTONS_MAY_VISIBLE], - [false, BUTTONS_NEVER_VISIBLE], + [1, BUTTONS_MAY_VISIBLE], + [0, BUTTONS_NEVER_VISIBLE], ]; const windowFeaturesValues = [ // Opens a popup @@ -77,7 +77,7 @@ add_task(async function titlebar_buttons_visibility() { const menuBarShownValues = [true, false]; for (const [drawInTitlebar, drawInTitlebarButtons] of drawInTitlebarValues) { - Services.prefs.setBoolPref("browser.tabs.drawInTitlebar", drawInTitlebar); + Services.prefs.setIntPref("browser.tabs.drawInTitlebar", drawInTitlebar); for (const [ windowFeatures, diff --git a/browser/base/content/test/startup/browser_preXULSkeletonUIRegistry.js b/browser/base/content/test/startup/browser_preXULSkeletonUIRegistry.js index 4a18807eb726..8afc7d7ae123 100644 --- a/browser/base/content/test/startup/browser_preXULSkeletonUIRegistry.js +++ b/browser/base/content/test/startup/browser_preXULSkeletonUIRegistry.js @@ -71,7 +71,7 @@ add_task(async function testWritesEnabledOnPrefChange() { is(enabled, 0, "Pre-XUL skeleton UI is disabled in the Windows registry"); Services.prefs.setBoolPref("browser.startup.preXulSkeletonUI", true); - Services.prefs.setBoolPref("browser.tabs.drawInTitlebar", false); + Services.prefs.setIntPref("browser.tabs.drawInTitlebar", 0); enabled = WindowsRegistry.readRegKey( Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, "Software\\Mozilla\\Firefox\\PreXULSkeletonUISettings", diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm index 9bdab2335eb2..4772993ae921 100644 --- a/browser/components/BrowserGlue.jsm +++ b/browser/components/BrowserGlue.jsm @@ -800,10 +800,7 @@ let JSWINDOWACTORS = { ); // Hide the titlebar if the actual browser window will draw in it. - let hiddenTitlebar = Services.prefs.getBoolPref( - "browser.tabs.drawInTitlebar", - win.matchMedia("(-moz-gtk-csd-hide-titlebar-by-default)").matches - ); + let hiddenTitlebar = Services.appinfo.drawInTitlebar; if (hiddenTitlebar) { win.windowUtils.setChromeMargin(0, 2, 2, 2); } diff --git a/browser/components/customizableui/CustomizableUI.jsm b/browser/components/customizableui/CustomizableUI.jsm index de7c20f15fb4..810ca51afa21 100644 --- a/browser/components/customizableui/CustomizableUI.jsm +++ b/browser/components/customizableui/CustomizableUI.jsm @@ -3151,12 +3151,8 @@ var CustomizableUIInternal = { _resetUIState() { try { - // kPrefDrawInTitlebar may not be defined on Linux/Gtk+ which throws an exception - // and leads to whole test failure. Let's set a fallback default value to avoid that, - // both titlebar states are tested anyway and it's not important which state is tested first. - gUIStateBeforeReset.drawInTitlebar = Services.prefs.getBoolPref( - kPrefDrawInTitlebar, - false + gUIStateBeforeReset.drawInTitlebar = Services.prefs.getIntPref( + kPrefDrawInTitlebar ); gUIStateBeforeReset.uiCustomizationState = Services.prefs.getCharPref( kPrefCustomizationState @@ -3246,7 +3242,7 @@ var CustomizableUIInternal = { this._clearPreviousUIState(); Services.prefs.setCharPref(kPrefCustomizationState, uiCustomizationState); - Services.prefs.setBoolPref(kPrefDrawInTitlebar, drawInTitlebar); + Services.prefs.setIntPref(kPrefDrawInTitlebar, drawInTitlebar); Services.prefs.setIntPref(kPrefUIDensity, uiDensity); Services.prefs.setBoolPref(kPrefAutoTouchMode, autoTouchMode); Services.prefs.setBoolPref( diff --git a/browser/components/customizableui/CustomizeMode.jsm b/browser/components/customizableui/CustomizeMode.jsm index d689a39fb5fc..9a88875a7d6a 100644 --- a/browser/components/customizableui/CustomizeMode.jsm +++ b/browser/components/customizableui/CustomizeMode.jsm @@ -1715,10 +1715,7 @@ CustomizeMode.prototype = { }, _updateTitlebarCheckbox() { - let drawInTitlebar = Services.prefs.getBoolPref( - kDrawInTitlebarPref, - this.window.matchMedia("(-moz-gtk-csd-hide-titlebar-by-default)").matches - ); + let drawInTitlebar = Services.appinfo.drawInTitlebar; let checkbox = this.$("customization-titlebar-visibility-checkbox"); // Drawing in the titlebar means 'hiding' the titlebar. // We use the attribute rather than a property because if we're not in @@ -1732,7 +1729,7 @@ CustomizeMode.prototype = { toggleTitlebar(aShouldShowTitlebar) { // Drawing in the titlebar means not showing the titlebar, hence the negation: - Services.prefs.setBoolPref(kDrawInTitlebarPref, !aShouldShowTitlebar); + Services.prefs.setIntPref(kDrawInTitlebarPref, !aShouldShowTitlebar); }, _getBoundsWithoutFlushing(element) { diff --git a/browser/components/customizableui/test/browser_970511_undo_restore_default.js b/browser/components/customizableui/test/browser_970511_undo_restore_default.js index 89ee03947f17..e662d5876fd5 100644 --- a/browser/components/customizableui/test/browser_970511_undo_restore_default.js +++ b/browser/components/customizableui/test/browser_970511_undo_restore_default.js @@ -142,11 +142,16 @@ add_task(async function() { // Bug 971626 - Restore Defaults should collapse the Title Bar add_task(async function() { - if (Services.appinfo.OS != "WINNT" && Services.appinfo.OS != "Darwin") { - return; + { + const supported = TabsInTitlebar.systemSupported; + is(typeof supported, "boolean"); + info("TabsInTitlebar support: " + supported); + if (!supported) { + return; + } } - let prefName = "browser.tabs.drawInTitlebar"; - let defaultValue = Services.prefs.getBoolPref(prefName); + + const kDefaultValue = Services.appinfo.drawInTitlebar; let restoreDefaultsButton = document.getElementById( "customization-reset-button" ); @@ -166,7 +171,7 @@ add_task(async function() { ); is( titlebarCheckbox.hasAttribute("checked"), - !defaultValue, + !kDefaultValue, "Title bar checkbox should reflect pref value" ); is( @@ -175,14 +180,20 @@ add_task(async function() { "Undo reset button should be hidden at start of test" ); - Services.prefs.setBoolPref(prefName, !defaultValue); + let prefName = "browser.tabs.drawInTitlebar"; + Services.prefs.setIntPref(prefName, !kDefaultValue); ok( !restoreDefaultsButton.disabled, "Restore defaults button should be enabled when pref changed" ); + is( + Services.appinfo.drawInTitlebar, + !kDefaultValue, + "Title bar checkbox should reflect changed pref value" + ); is( titlebarCheckbox.hasAttribute("checked"), - defaultValue, + kDefaultValue, "Title bar checkbox should reflect changed pref value" ); ok( @@ -202,14 +213,19 @@ add_task(async function() { ); is( titlebarCheckbox.hasAttribute("checked"), - !defaultValue, + !kDefaultValue, "Title bar checkbox should reflect default value after reset" ); is( - Services.prefs.getBoolPref(prefName), - defaultValue, + Services.prefs.getIntPref(prefName), + 2, "Reset should reset drawInTitlebar" ); + is( + Services.appinfo.drawInTitlebar, + kDefaultValue, + "Default state should be restored" + ); ok(CustomizableUI.inDefaultState, "In default state after titlebar reset"); is( undoResetButton.hidden, @@ -228,13 +244,13 @@ add_task(async function() { ); is( titlebarCheckbox.hasAttribute("checked"), - defaultValue, + kDefaultValue, "Title bar checkbox should reflect undo-reset value" ); ok(!CustomizableUI.inDefaultState, "No longer in default state after undo"); is( - Services.prefs.getBoolPref(prefName), - !defaultValue, + Services.prefs.getIntPref(prefName), + kDefaultValue ? 0 : 1, "Undo-reset goes back to previous pref value" ); is( diff --git a/browser/modules/BrowserUsageTelemetry.jsm b/browser/modules/BrowserUsageTelemetry.jsm index ab7a70a71f10..85305e879d82 100644 --- a/browser/modules/BrowserUsageTelemetry.jsm +++ b/browser/modules/BrowserUsageTelemetry.jsm @@ -497,9 +497,7 @@ let BrowserUsageTelemetry = { case "browser.tabs.drawInTitlebar": this._recordWidgetChange( "titlebar", - Services.prefs.getBoolPref("browser.tabs.drawInTitlebar") - ? "off" - : "on", + Services.appinfo.drawInTitlebar ? "off" : "on", "pref" ); break; @@ -601,12 +599,7 @@ let BrowserUsageTelemetry = { widgetMap.set("menu-toolbar", menuBarHidden ? "off" : "on"); // Drawing in the titlebar means not showing the titlebar, hence the negation. - widgetMap.set( - "titlebar", - Services.prefs.getBoolPref("browser.tabs.drawInTitlebar", true) - ? "off" - : "on" - ); + widgetMap.set("titlebar", Services.appinfo.drawInTitlebar ? "off" : "on"); for (let area of CustomizableUI.areas) { if (!(area in BROWSER_UI_CONTAINER_IDS)) { diff --git a/browser/modules/test/browser/browser_UsageTelemetry_toolbars.js b/browser/modules/test/browser/browser_UsageTelemetry_toolbars.js index 4f4b4578764f..db9208a61aa7 100644 --- a/browser/modules/test/browser/browser_UsageTelemetry_toolbars.js +++ b/browser/modules/test/browser/browser_UsageTelemetry_toolbars.js @@ -111,7 +111,7 @@ function organizeToolbars(state = {}) { targetState.personalToolbarVisible ); - Services.prefs.setBoolPref( + Services.prefs.setIntPref( "browser.tabs.drawInTitlebar", !targetState.titlebarVisible ); diff --git a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/TabsInTitlebar.jsm b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/TabsInTitlebar.jsm index a728c9764fcf..06578da776f5 100644 --- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/TabsInTitlebar.jsm +++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/TabsInTitlebar.jsm @@ -17,10 +17,7 @@ var TabsInTitlebar = { tabsInTitlebar: { selectors: ["#navigator-toolbox"], async applyConfig() { - if (Services.appinfo.OS == "Linux") { - return "TabsInTitlebar isn't supported on Linux"; - } - Services.prefs.setBoolPref(PREF_TABS_IN_TITLEBAR, true); + Services.prefs.setIntPref(PREF_TABS_IN_TITLEBAR, 1); return undefined; }, }, @@ -30,7 +27,7 @@ var TabsInTitlebar = { Services.appinfo.OS == "Linux" ? [] : ["#titlebar"] ), async applyConfig() { - Services.prefs.setBoolPref(PREF_TABS_IN_TITLEBAR, false); + Services.prefs.setIntPref(PREF_TABS_IN_TITLEBAR, 0); }, }, }, diff --git a/layout/style/test/chrome/bug418986-2.js b/layout/style/test/chrome/bug418986-2.js index 9da3b9d86233..8bca6f4b2150 100644 --- a/layout/style/test/chrome/bug418986-2.js +++ b/layout/style/test/chrome/bug418986-2.js @@ -61,7 +61,6 @@ var suppressed_toggles = [ "-moz-windows-default-theme", "-moz-windows-glass", "-moz-gtk-csd-available", - "-moz-gtk-csd-hide-titlebar-by-default", "-moz-gtk-csd-minimize-button", "-moz-gtk-csd-maximize-button", "-moz-gtk-csd-close-button", diff --git a/layout/style/test/chrome/chrome-only-media-queries.js b/layout/style/test/chrome/chrome-only-media-queries.js index 5ccde7bc9256..605580a0988c 100644 --- a/layout/style/test/chrome/chrome-only-media-queries.js +++ b/layout/style/test/chrome/chrome-only-media-queries.js @@ -21,7 +21,6 @@ const CHROME_ONLY_TOGGLES = [ "-moz-windows-non-native-menus", "-moz-swipe-animation-enabled", "-moz-gtk-csd-available", - "-moz-gtk-csd-hide-titlebar-by-default", "-moz-gtk-csd-minimize-button", "-moz-gtk-csd-maximize-button", "-moz-gtk-csd-close-button", diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 052c4f7db5cc..7bc51a1479aa 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -1300,6 +1300,14 @@ value: false mirror: always +# Whether we should draw the tabs on top of the titlebar. +# +# no (0), yes (1), or default (2), which is true everywhere except Linux. +- name: browser.tabs.drawInTitlebar + type: int32_t + value: 2 + mirror: always + # If set, use DocumentChannel to directly initiate loads entirely # from parent-process BrowsingContexts - name: browser.tabs.documentchannel.parent-controlled diff --git a/servo/components/style/gecko/media_features.rs b/servo/components/style/gecko/media_features.rs index 34bcda32e109..40a34095d6f6 100644 --- a/servo/components/style/gecko/media_features.rs +++ b/servo/components/style/gecko/media_features.rs @@ -651,7 +651,7 @@ macro_rules! bool_pref_feature { /// to support new types in these entries and (2) ensuring that either /// nsPresContext::MediaFeatureValuesChanged is called when the value that /// would be returned by the evaluator function could change. -pub static MEDIA_FEATURES: [MediaFeatureDescription; 59] = [ +pub static MEDIA_FEATURES: [MediaFeatureDescription; 58] = [ feature!( atom!("width"), AllowsRanges::Yes, @@ -890,7 +890,6 @@ pub static MEDIA_FEATURES: [MediaFeatureDescription; 59] = [ lnf_int_feature!(atom!("-moz-windows-glass"), WindowsGlass), lnf_int_feature!(atom!("-moz-swipe-animation-enabled"), SwipeAnimationEnabled), lnf_int_feature!(atom!("-moz-gtk-csd-available"), GTKCSDAvailable), - lnf_int_feature!(atom!("-moz-gtk-csd-hide-titlebar-by-default"), GTKCSDHideTitlebarByDefault), lnf_int_feature!(atom!("-moz-gtk-csd-minimize-button"), GTKCSDMinimizeButton), lnf_int_feature!(atom!("-moz-gtk-csd-maximize-button"), GTKCSDMaximizeButton), lnf_int_feature!(atom!("-moz-gtk-csd-close-button"), GTKCSDCloseButton), diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index c9ea8cdc6e18..5e18ea7672a0 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -23,6 +23,7 @@ #include "mozilla/Printf.h" #include "mozilla/ResultExtensions.h" #include "mozilla/ScopeExit.h" +#include "mozilla/StaticPrefs_browser.h" #include "mozilla/StaticPrefs_fission.h" #include "mozilla/Telemetry.h" #include "mozilla/Utf8.h" @@ -276,7 +277,6 @@ static const char kPrefThemeId[] = "extensions.activeThemeID"; static const char kPrefBrowserStartupBlankWindow[] = "browser.startup.blankWindow"; static const char kPrefPreXulSkeletonUI[] = "browser.startup.preXulSkeletonUI"; -static const char kPrefDrawTabsInTitlebar[] = "browser.tabs.drawInTitlebar"; #endif // defined(XP_WIN) int gArgc; @@ -1331,6 +1331,12 @@ nsXULAppInfo::GetChromeColorSchemeIsDark(bool* aResult) { return NS_OK; } +NS_IMETHODIMP +nsXULAppInfo::GetDrawInTitlebar(bool* aResult) { + *aResult = LookAndFeel::DrawInTitlebar(); + return NS_OK; +} + NS_IMETHODIMP nsXULAppInfo::GetProcessStartupShortcut(nsAString& aShortcut) { #if defined(XP_WIN) @@ -1996,7 +2002,7 @@ static void ReflectSkeletonUIPrefToRegistry(const char* aPref, void* aData) { bool shouldBeEnabled = Preferences::GetBool(kPrefPreXulSkeletonUI, false) && Preferences::GetBool(kPrefBrowserStartupBlankWindow, false) && - Preferences::GetBool(kPrefDrawTabsInTitlebar, false); + LookAndFeel::DrawInTitlebar(); if (shouldBeEnabled && Preferences::HasUserValue(kPrefThemeId)) { nsCString themeId; Preferences::GetCString(kPrefThemeId, themeId); @@ -2025,8 +2031,9 @@ static void SetupSkeletonUIPrefs() { Preferences::RegisterCallback(&ReflectSkeletonUIPrefToRegistry, kPrefBrowserStartupBlankWindow); Preferences::RegisterCallback(&ReflectSkeletonUIPrefToRegistry, kPrefThemeId); - Preferences::RegisterCallback(&ReflectSkeletonUIPrefToRegistry, - kPrefDrawTabsInTitlebar); + Preferences::RegisterCallback( + &ReflectSkeletonUIPrefToRegistry, + nsDependentCString(StaticPrefs::GetPrefName_browser_tabs_drawInTitlebar())); } # if defined(MOZ_LAUNCHER_PROCESS) diff --git a/widget/LookAndFeel.h b/widget/LookAndFeel.h index 397a8fd86b9b..ba9353406359 100644 --- a/widget/LookAndFeel.h +++ b/widget/LookAndFeel.h @@ -246,12 +246,6 @@ class LookAndFeel { */ GTKCSDAvailable, - /* - * A boolean value indicating whether GTK+ system titlebar should be - * disabled by default. - */ - GTKCSDHideTitlebarByDefault, - /* * A boolean value indicating whether client-side decorations should * contain a minimize button. @@ -509,6 +503,11 @@ class LookAndFeel { */ static bool GetEchoPassword(); + /** + * Whether we should be drawing in the titlebar by default. + */ + static bool DrawInTitlebar(); + /** * The millisecond to mask password value. * This value is only valid when GetEchoPassword() returns true. diff --git a/widget/gtk/nsLookAndFeel.cpp b/widget/gtk/nsLookAndFeel.cpp index 7cab3abbfb15..8ccee16dea83 100644 --- a/widget/gtk/nsLookAndFeel.cpp +++ b/widget/gtk/nsLookAndFeel.cpp @@ -789,10 +789,6 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) { EnsureInit(); aResult = mCSDAvailable; break; - case IntID::GTKCSDHideTitlebarByDefault: - EnsureInit(); - aResult = mCSDHideTitlebarByDefault; - break; case IntID::GTKCSDMaximizeButton: EnsureInit(); aResult = mCSDMaximizeButton; @@ -1246,7 +1242,6 @@ void nsLookAndFeel::EnsureInit() { mCSDAvailable = nsWindow::GtkWindowDecoration() != nsWindow::GTK_DECORATION_NONE; - mCSDHideTitlebarByDefault = nsWindow::HideTitlebarByDefault(); mSystemTheme.Init(); @@ -1840,6 +1835,29 @@ char16_t nsLookAndFeel::GetPasswordCharacterImpl() { bool nsLookAndFeel::GetEchoPasswordImpl() { return false; } +bool nsLookAndFeel::GetDefaultDrawInTitlebar() { + static bool drawInTitlebar = []() { + // When user defined widget.default-hidden-titlebar don't do any + // heuristics and just follow it. + if (Preferences::HasUserValue("widget.default-hidden-titlebar")) { + return Preferences::GetBool("widget.default-hidden-titlebar", false); + } + + // Don't hide titlebar when it's disabled on current desktop. + const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP"); + if (!currentDesktop || nsWindow::GetSystemGtkWindowDecoration() == + nsWindow::GTK_DECORATION_NONE) { + return false; + } + + // We hide system titlebar on Gnome/ElementaryOS without any restriction. + return strstr(currentDesktop, "GNOME-Flashback:GNOME") || + strstr(currentDesktop, "GNOME") || + strstr(currentDesktop, "Pantheon"); + }(); + return drawInTitlebar; +} + void nsLookAndFeel::GetThemeInfo(nsACString& aInfo) { aInfo.Append(mSystemTheme.mName); aInfo.Append(" / "); diff --git a/widget/gtk/nsLookAndFeel.h b/widget/gtk/nsLookAndFeel.h index aa79710db963..540313c106fd 100644 --- a/widget/gtk/nsLookAndFeel.h +++ b/widget/gtk/nsLookAndFeel.h @@ -32,6 +32,8 @@ class nsLookAndFeel final : public nsXPLookAndFeel { char16_t GetPasswordCharacterImpl() override; bool GetEchoPasswordImpl() override; + bool GetDefaultDrawInTitlebar() override; + template void WithAltThemeConfigured(const Callback&); @@ -155,7 +157,6 @@ class nsLookAndFeel final : public nsXPLookAndFeel { int32_t mCaretBlinkTime = 0; int32_t mCaretBlinkCount = -1; bool mCSDAvailable = false; - bool mCSDHideTitlebarByDefault = false; bool mCSDMaximizeButton = false; bool mCSDMinimizeButton = false; bool mCSDCloseButton = false; diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index cfd56533c055..cf48ca593d58 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -8720,29 +8720,6 @@ bool nsWindow::TitlebarUseShapeMask() { return useShapeMask; } -bool nsWindow::HideTitlebarByDefault() { - static int hideTitlebar = []() { - // When user defined widget.default-hidden-titlebar don't do any - // heuristics and just follow it. - if (Preferences::HasUserValue("widget.default-hidden-titlebar")) { - return Preferences::GetBool("widget.default-hidden-titlebar", false); - } - - // Don't hide titlebar when it's disabled on current desktop. - const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP"); - if (!currentDesktop || - GetSystemGtkWindowDecoration() == GTK_DECORATION_NONE) { - return false; - } - - // We hide system titlebar on Gnome/ElementaryOS without any restriction. - return ((strstr(currentDesktop, "GNOME-Flashback:GNOME") != nullptr || - strstr(currentDesktop, "GNOME") != nullptr || - strstr(currentDesktop, "Pantheon") != nullptr)); - }(); - return hideTitlebar; -} - int32_t nsWindow::RoundsWidgetCoordinatesTo() { return GdkCeiledScaleFactor(); } void nsWindow::GetCompositorWidgetInitData( diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h index da321a7be649..02901cb48703 100644 --- a/widget/gtk/nsWindow.h +++ b/widget/gtk/nsWindow.h @@ -367,7 +367,6 @@ class nsWindow final : public nsBaseWidget { */ static GtkWindowDecoration GetSystemGtkWindowDecoration(); - static bool HideTitlebarByDefault(); static bool GetTopLevelWindowActiveState(nsIFrame* aFrame); static bool TitlebarUseShapeMask(); bool IsRemoteContent() { return HasRemoteContent(); } diff --git a/widget/headless/HeadlessLookAndFeelGTK.cpp b/widget/headless/HeadlessLookAndFeelGTK.cpp index 067f0750ac32..d072a4fb8709 100644 --- a/widget/headless/HeadlessLookAndFeelGTK.cpp +++ b/widget/headless/HeadlessLookAndFeelGTK.cpp @@ -256,7 +256,6 @@ nsresult HeadlessLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) { aResult = 1; break; case IntID::GTKCSDAvailable: - case IntID::GTKCSDHideTitlebarByDefault: aResult = 0; break; case IntID::GTKCSDMinimizeButton: diff --git a/widget/nsXPLookAndFeel.cpp b/widget/nsXPLookAndFeel.cpp index 62eed79b9bd7..5f6799809304 100644 --- a/widget/nsXPLookAndFeel.cpp +++ b/widget/nsXPLookAndFeel.cpp @@ -160,7 +160,6 @@ static const char sIntPrefs[][43] = { "ui.contextMenuOffsetVertical", "ui.contextMenuOffsetHorizontal", "ui.GtkCSDAvailable", - "ui.GtkCSDHideTitlebarByDefault", "ui.GtkCSDMinimizeButton", "ui.GtkCSDMaximizeButton", "ui.GtkCSDCloseButton", @@ -1266,6 +1265,18 @@ uint32_t LookAndFeel::GetPasswordMaskDelay() { return delay; } +bool LookAndFeel::DrawInTitlebar() { + switch (StaticPrefs::browser_tabs_drawInTitlebar()) { + case 0: + return false; + case 1: + return true; + default: + break; + } + return nsLookAndFeel::GetInstance()->GetDefaultDrawInTitlebar(); +} + void LookAndFeel::GetThemeInfo(nsACString& aOut) { nsLookAndFeel::GetInstance()->GetThemeInfo(aOut); } diff --git a/widget/nsXPLookAndFeel.h b/widget/nsXPLookAndFeel.h index 05e75f709906..3218c9c7bd02 100644 --- a/widget/nsXPLookAndFeel.h +++ b/widget/nsXPLookAndFeel.h @@ -56,6 +56,8 @@ class nsXPLookAndFeel : public mozilla::LookAndFeel { virtual uint32_t GetPasswordMaskDelayImpl() { return 600; } + virtual bool GetDefaultDrawInTitlebar() { return true; } + static bool LookAndFeelFontToStyle(const LookAndFeelFont&, nsString& aName, gfxFontStyle&); static LookAndFeelFont StyleToLookAndFeelFont(const nsAString& aName, diff --git a/xpcom/ds/StaticAtoms.py b/xpcom/ds/StaticAtoms.py index 7aa15cfc09b0..22244864d4ea 100644 --- a/xpcom/ds/StaticAtoms.py +++ b/xpcom/ds/StaticAtoms.py @@ -2225,7 +2225,6 @@ STATIC_ATOMS = [ Atom("_moz_is_resource_document", "-moz-is-resource-document"), Atom("_moz_swipe_animation_enabled", "-moz-swipe-animation-enabled"), Atom("_moz_gtk_csd_available", "-moz-gtk-csd-available"), - Atom("_moz_gtk_csd_hide_titlebar_by_default", "-moz-gtk-csd-hide-titlebar-by-default"), Atom("_moz_gtk_csd_titlebar_radius", "-moz-gtk-csd-titlebar-radius"), Atom("_moz_gtk_csd_minimize_button", "-moz-gtk-csd-minimize-button"), Atom("_moz_gtk_csd_maximize_button", "-moz-gtk-csd-maximize-button"), diff --git a/xpcom/system/nsIXULRuntime.idl b/xpcom/system/nsIXULRuntime.idl index 8855ff0d8c0d..e0b88396d652 100644 --- a/xpcom/system/nsIXULRuntime.idl +++ b/xpcom/system/nsIXULRuntime.idl @@ -319,6 +319,9 @@ interface nsIXULRuntime : nsISupports /** Whether the chrome color-scheme is dark */ readonly attribute boolean chromeColorSchemeIsDark; + /** Whether we should draw over the titlebar */ + readonly attribute boolean drawInTitlebar; + /** * The path of the shortcut used to start the current process, or "" if none. *