Bug 1005098 - don't update titlebar attributes before the window has been activated, r?MattN
--- a/browser/base/content/browser-tabsintitlebar.js
+++ b/browser/base/content/browser-tabsintitlebar.js
@@ -74,16 +74,17 @@ var TabsInTitlebar = {
}
}
},
_initialized: false,
_disallowed: {},
_prefName: "browser.tabs.drawInTitlebar",
_lastSizeMode: null,
+ haveUpdatedTitlebarDisplay: false,
_readPref: function () {
this.allowedBy("pref",
Services.prefs.getBoolPref(this._prefName));
},
_update: function (aForce=false) {
let $ = id => document.getElementById(id);
@@ -258,16 +259,32 @@ var TabsInTitlebar = {
this._initialized = false;
Services.prefs.removeObserver(this._prefName, this);
this._menuObserver.disconnect();
CustomizableUI.removeListener(this);
}
};
function updateTitlebarDisplay() {
+ // On Windows, trying to run this before the window has been activated
+ // results in Bad Things Happening. Prevent us from doing that:
+ if (!TabsInTitlebar.haveUpdatedTitlebarDisplay) {
+ if (AppConstants.platform == "win" && Services.focus.activeWindow != window) {
+ if (!TabsInTitlebar._titlebarUpdateListener) {
+ TabsInTitlebar._titlebarUpdateListener = e => {
+ window.removeEventListener("activate", TabsInTitlebar._titlebarUpdateListener);
+ updateTitlebarDisplay();
+ };
+ window.addEventListener("activate", TabsInTitlebar._titlebarUpdateListener);
+ }
+ return;
+ }
+ TabsInTitlebar.haveUpdatedTitlebarDisplay = true;
+ }
+
if (AppConstants.platform == "macosx") {
// OS X and the other platforms differ enough to necessitate this kind of
// special-casing. Like the other platforms where we CAN_DRAW_IN_TITLEBAR,
// we draw in the OS X titlebar when putting the tabs up there. However, OS X
// also draws in the titlebar when a lightweight theme is applied, regardless
// of whether or not the tabs are drawn in the titlebar.
if (TabsInTitlebar.enabled) {
document.documentElement.setAttribute("chromemargin-nonlwtheme", "0,-1,-1,-1");