summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbrowser/base/content/browser.js17
-rw-r--r--widget/windows/nsWindow.cpp2
2 files changed, 19 insertions, 0 deletions
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index d813a55cc..bbfef0049 100755
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -8075,6 +8075,7 @@ var ToolbarIconColor = {
window.addEventListener("activate", this);
window.addEventListener("deactivate", this);
Services.obs.addObserver(this, "lightweight-theme-styling-update", false);
+ gPrefService.addObserver("ui.colorChanged", this, false);
// If the window isn't active now, we assume that it has never been active
// before and will soon become active such that inferFromText will be
@@ -8089,6 +8090,7 @@ var ToolbarIconColor = {
window.removeEventListener("activate", this);
window.removeEventListener("deactivate", this);
Services.obs.removeObserver(this, "lightweight-theme-styling-update");
+ gPrefService.removeObserver("ui.colorChanged", this);
},
handleEvent: function (event) {
@@ -8107,6 +8109,18 @@ var ToolbarIconColor = {
// lightweight-theme-styling-update observer.
setTimeout(() => { this.inferFromText(); }, 0);
break;
+ case "nsPref:changed":
+ // system color change
+ var colorChangedPref = false;
+ try {
+ colorChangedPref = gPrefService.getBoolPref("ui.colorChanged");
+ } catch(e) { }
+ // if pref indicates change, call inferFromText() on a small delay
+ if (colorChangedPref == true)
+ setTimeout(() => { this.inferFromText(); }, 300);
+ break;
+ default:
+ console.error("ToolbarIconColor: Uncaught topic " + aTopic);
}
},
@@ -8140,6 +8154,9 @@ var ToolbarIconColor = {
else
toolbar.setAttribute("brighttext", "true");
}
+
+ // Clear pref if set, since we're done applying the color changes.
+ gPrefService.clearUserPref("ui.colorChanged");
}
}
diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp
index e721267ba..a8923f78e 100644
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -7141,8 +7141,10 @@ nsWindow::OnSysColorChanged()
NotifySysColorChanged();
// On Windows 10 only, we trigger a theme change to pick up changed media
// queries that are needed for accent color changes.
+ // We also set a temp pref to notify the FE that the colors have changed.
if (IsWin10OrLater()) {
NotifyThemeChanged();
+ Preferences::SetBool("ui.colorChanged", true);
}
}
}