From 3f3f8f71528de902d81175366d255addf737739e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 5 Dec 2022 19:30:35 +0000 Subject: [PATCH] Bug 1802734 - Use non-native menus in Win10+ HCM. r=Gijs,ayeddi I thought of adding that border-y thing, but no other native menus have them on Win11 at least (tried Explorer and Settings). It should be doable tho, lmk if you insist. Differential Revision: https://phabricator.services.mozilla.com/D163172 --- widget/nsXPLookAndFeel.cpp | 2 +- widget/windows/nsLookAndFeel.cpp | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/widget/nsXPLookAndFeel.cpp b/widget/nsXPLookAndFeel.cpp index 65882059d2b4..9be1e9a0cce9 100644 --- a/widget/nsXPLookAndFeel.cpp +++ b/widget/nsXPLookAndFeel.cpp @@ -493,7 +493,7 @@ bool LookAndFeel::WindowsNonNativeMenusEnabled() { return true; default: #ifdef XP_WIN - return GetInt(IntID::WindowsDefaultTheme) && IsWin10OrLater(); + return IsWin10OrLater(); #else return false; #endif diff --git a/widget/windows/nsLookAndFeel.cpp b/widget/windows/nsLookAndFeel.cpp index 15bfad2e85be..a4feb1859b90 100644 --- a/widget/windows/nsLookAndFeel.cpp +++ b/widget/windows/nsLookAndFeel.cpp @@ -85,6 +85,13 @@ void nsLookAndFeel::RefreshImpl() { nsXPLookAndFeel::RefreshImpl(); } +static bool UseNonNativeMenuColors() { + if (!LookAndFeel::WindowsNonNativeMenusEnabled()) { + return false; + } + return LookAndFeel::GetInt(LookAndFeel::IntID::WindowsDefaultTheme); +} + nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, nscolor& aColor) { EnsureInit(); @@ -92,7 +99,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, auto IsHighlightColor = [&] { switch (aID) { case ColorID::MozMenuhover: - return !LookAndFeel::WindowsNonNativeMenusEnabled(); + return !UseNonNativeMenuColors(); case ColorID::Highlight: case ColorID::Selecteditem: // We prefer the generic dark selection color if we don't have an @@ -109,7 +116,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, auto IsHighlightTextColor = [&] { switch (aID) { case ColorID::MozMenubarhovertext: - if (LookAndFeel::WindowsNonNativeMenusEnabled()) { + if (UseNonNativeMenuColors()) { return false; } if (!nsUXThemeData::IsAppThemed()) { @@ -117,7 +124,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, } [[fallthrough]]; case ColorID::MozMenuhovertext: - if (LookAndFeel::WindowsNonNativeMenusEnabled()) { + if (UseNonNativeMenuColors()) { return false; } return !mColorMenuHoverText; @@ -227,7 +234,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, idx = COLOR_GRAYTEXT; break; case ColorID::MozMenubarhovertext: - if (LookAndFeel::WindowsNonNativeMenusEnabled()) { + if (UseNonNativeMenuColors()) { aColor = kNonNativeMenuText; return NS_OK; } @@ -237,7 +244,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, } [[fallthrough]]; case ColorID::MozMenuhovertext: - if (LookAndFeel::WindowsNonNativeMenusEnabled()) { + if (UseNonNativeMenuColors()) { aColor = kNonNativeMenuText; return NS_OK; } @@ -248,11 +255,11 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, idx = COLOR_HIGHLIGHTTEXT; break; case ColorID::MozMenuhover: - MOZ_ASSERT(LookAndFeel::WindowsNonNativeMenusEnabled()); + MOZ_ASSERT(UseNonNativeMenuColors()); aColor = NS_RGB(0xe0, 0xe0, 0xe6); return NS_OK; case ColorID::MozMenuhoverdisabled: - if (LookAndFeel::WindowsNonNativeMenusEnabled()) { + if (UseNonNativeMenuColors()) { aColor = NS_RGB(0xf0, 0xf0, 0xf3); return NS_OK; } @@ -274,7 +281,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, idx = COLOR_INFOTEXT; break; case ColorID::Menu: - if (LookAndFeel::WindowsNonNativeMenusEnabled()) { + if (UseNonNativeMenuColors()) { aColor = NS_RGB(0xf9, 0xf9, 0xfb); return NS_OK; } @@ -282,7 +289,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, break; case ColorID::Menutext: case ColorID::MozMenubartext: - if (LookAndFeel::WindowsNonNativeMenusEnabled()) { + if (UseNonNativeMenuColors()) { aColor = kNonNativeMenuText; return NS_OK; }