Bug 581726 - Disable tab previews for windows that have panorama displayed. r=dao, a=2.0.
authorJim Mathies <jmathies@mozilla.com>
Sat, 05 Feb 2011 14:22:24 -0600
changeset 61987 953be21166fee9b361f5edb1cac13a12b2264ed5
parent 61986 68881eaeeebb69f1085793714589468c72d2f0f6
child 61988 c14987c4d6a00b5c65656caacb3f0c52b9a8d133
push idunknown
push userunknown
push dateunknown
reviewersdao, 2.0
bugs581726
milestone2.0b12pre
Bug 581726 - Disable tab previews for windows that have panorama displayed. r=dao, a=2.0.
browser/components/wintaskbar/WindowsPreviewPerTab.jsm
--- a/browser/components/wintaskbar/WindowsPreviewPerTab.jsm
+++ b/browser/components/wintaskbar/WindowsPreviewPerTab.jsm
@@ -405,42 +405,48 @@ XPCOMUtils.defineLazyGetter(PreviewContr
  *        The nsIDOMWindow browser window 
  */
 function TabWindow(win) {
   this.win = win;
   this.tabbrowser = win.gBrowser;
 
   this.previews = [];
 
-  for (let i = 0; i < this.events.length; i++)
-    this.tabbrowser.tabContainer.addEventListener(this.events[i], this, false);
+  for (let i = 0; i < this.tabEvents.length; i++)
+    this.tabbrowser.tabContainer.addEventListener(this.tabEvents[i], this, false);
   this.tabbrowser.addTabsProgressListener(this);
 
+  for (let i = 0; i < this.winEvents.length; i++)
+    this.win.addEventListener(this.winEvents[i], this, false);
+
   AeroPeek.windows.push(this);
   let tabs = this.tabbrowser.tabs;
   for (let i = 0; i < tabs.length; i++)
     this.newTab(tabs[i]);
 
   this.updateTabOrdering();
   AeroPeek.checkPreviewCount();
 }
 
 TabWindow.prototype = {
   _enabled: false,
-  events: ["TabOpen", "TabClose", "TabSelect", "TabMove"],
+  tabEvents: ["TabOpen", "TabClose", "TabSelect", "TabMove"],
+  winEvents: ["tabviewshown", "tabviewhidden"],
 
   destroy: function () {
     this._destroying = true;
 
     let tabs = this.tabbrowser.tabs;
 
     this.tabbrowser.removeTabsProgressListener(this);
+    for (let i = 0; i < this.tabEvents.length; i++)
+      this.tabbrowser.tabContainer.removeEventListener(this.tabEvents[i], this, false);
 
-    for (let i = 0; i < this.events.length; i++)
-      this.tabbrowser.tabContainer.removeEventListener(this.events[i], this, false);
+    for (let i = 0; i < this.winEvents.length; i++)
+      this.win.removeEventListener(this.winEvents[i], this, false);
 
     for (let i = 0; i < tabs.length; i++)
       this.removeTab(tabs[i]);
 
     let idx = AeroPeek.windows.indexOf(this.win.gTaskbarTabGroup);
     AeroPeek.windows.splice(idx, 1);
     AeroPeek.checkPreviewCount();
   },
@@ -549,16 +555,22 @@ TabWindow.prototype = {
       case "TabMove":
         let oldPos = evt.detail;
         let newPos = tab._tPos;
         let preview = this.previews[oldPos];
         this.previews.splice(oldPos, 1);
         this.previews.splice(newPos, 0, preview);
         this.updateTabOrdering();
         break;
+      case "tabviewshown":
+        this.enabled = false;
+        break;
+      case "tabviewhidden":
+        this.enabled = true;
+        break;
     }
   },
 
   //// Browser progress listener
   onLinkIconAvailable: function (aBrowser, aIconURL) {
     let self = this;
     getFaviconAsImage(aIconURL, function (img) {
       let index = self.tabbrowser.browsers.indexOf(aBrowser);