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
This commit is contained in:
Emilio Cobos Álvarez 2022-12-05 19:30:35 +00:00
Родитель 5a655472a8
Коммит 3f3f8f7152
2 изменённых файлов: 17 добавлений и 10 удалений

Просмотреть файл

@ -493,7 +493,7 @@ bool LookAndFeel::WindowsNonNativeMenusEnabled() {
return true;
default:
#ifdef XP_WIN
return GetInt(IntID::WindowsDefaultTheme) && IsWin10OrLater();
return IsWin10OrLater();
#else
return false;
#endif

Просмотреть файл

@ -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;
}