mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 20:01:50 +00:00
Bug 1756082 - Properly support ui.systemUsesDarkMode switching on Linux. r=karlt
So the issue here is that GTK's nsLookAndFeel doesn't know about the effective value of the pref, and thus ends up potentially choosing the wrong GTK theme (and thus choosing light system colors, but thinking that we can paint the textfield background natively with GTK, which would have a dark background, for example). The right fix here is treating the pref as a stronger hint than the ColorSchemePreference that we compute from DBUS for the same purpose. This makes us follow the same code-path as if the system had specified dark mode itself, fixing the contrast issue. While at it, fix dynamic changes to this pref, which need to update system colors. Differential Revision: https://phabricator.services.mozilla.com/D139093
This commit is contained in:
parent
2229d1b1c0
commit
96533d3817
@ -1302,6 +1302,17 @@ void nsLookAndFeel::ConfigureAndInitializeAltTheme() {
|
||||
}
|
||||
|
||||
Maybe<ColorScheme> nsLookAndFeel::ComputeColorSchemeSetting() {
|
||||
{
|
||||
// Check the pref explicitly here. Usually this shouldn't be needed, but
|
||||
// since we can only load one GTK theme at a time, and the pref will
|
||||
// override the effective value that the rest of gecko assumes for the
|
||||
// "system" color scheme, we need to factor it in our GTK theme decisions.
|
||||
int32_t pref = 0;
|
||||
if (NS_SUCCEEDED(Preferences::GetInt("ui.systemUsesDarkTheme", &pref))) {
|
||||
return Some(pref ? ColorScheme::Dark : ColorScheme::Light);
|
||||
}
|
||||
}
|
||||
|
||||
if (!mDBusSettingsProxy) {
|
||||
return Nothing();
|
||||
}
|
||||
|
@ -375,10 +375,14 @@ void nsXPLookAndFeel::Shutdown() {
|
||||
widget::Theme::Shutdown();
|
||||
}
|
||||
|
||||
static void IntPrefChanged() {
|
||||
// Int prefs can't change our system colors or fonts.
|
||||
LookAndFeel::NotifyChangedAllWindows(
|
||||
widget::ThemeChangeKind::MediaQueriesOnly);
|
||||
static void IntPrefChanged(const nsACString& aPref) {
|
||||
// Most Int prefs can't change our system colors or fonts, but
|
||||
// ui.systemUsesDarkTheme can, since it affects the effective color-scheme
|
||||
// (affecting system colors).
|
||||
auto changeKind = aPref.EqualsLiteral("ui.systemUsesDarkTheme")
|
||||
? widget::ThemeChangeKind::Style
|
||||
: widget::ThemeChangeKind::MediaQueriesOnly;
|
||||
LookAndFeel::NotifyChangedAllWindows(changeKind);
|
||||
}
|
||||
|
||||
static void FloatPrefChanged() {
|
||||
@ -397,7 +401,7 @@ void nsXPLookAndFeel::OnPrefChanged(const char* aPref, void* aClosure) {
|
||||
nsDependentCString prefName(aPref);
|
||||
for (const char* pref : sIntPrefs) {
|
||||
if (prefName.Equals(pref)) {
|
||||
IntPrefChanged();
|
||||
IntPrefChanged(prefName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user