Bug 715679 - Handle more than one window correctly in Gonk, r=cjones
authorMichael Wu <mwu@mozilla.com>
Thu, 05 Jan 2012 13:23:34 -0800
changeset 86353 b0ec2c8e105561269d27f1a9545f4b568064e2fd
parent 86352 bdce0ad479d76b7ba943531658726a26d0b6342b
child 86354 91a8e4c55adbc9d8024cfe416d143446c291420b
push idunknown
push userunknown
push dateunknown
reviewerscjones
bugs715679
milestone12.0a1
Bug 715679 - Handle more than one window correctly in Gonk, r=cjones
widget/gonk/nsWindow.cpp
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -186,22 +186,35 @@ nsWindow::Destroy(void)
 }
 
 NS_IMETHODIMP
 nsWindow::Show(bool aState)
 {
     if (mWindowType == eWindowType_invisible)
         return NS_OK;
 
+    if (mVisible == aState)
+        return NS_OK;
+
     mVisible = aState;
     if (!IS_TOPLEVEL())
         return mParent ? mParent->Show(aState) : NS_OK;
 
-    if (aState)
+    if (aState) {
         BringToTop();
+    } else {
+        for (unsigned int i = 0; i < sTopWindows.Length(); i++) {
+            nsWindow *win = sTopWindows[i];
+            if (!win->mVisible)
+                continue;
+
+            win->BringToTop();
+            break;
+        }
+    }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWindow::IsVisible(bool & aState)
 {
     aState = mVisible;
@@ -282,20 +295,18 @@ nsWindow::ConfigureChildren(const nsTArr
 
 NS_IMETHODIMP
 nsWindow::Invalidate(const nsIntRect &aRect,
                      bool aIsSynchronous)
 {
     nsWindow *parent = mParent;
     while (parent && parent != sTopWindows[0])
         parent = parent->mParent;
-    if (parent != sTopWindows[0]) {
-        LOG("  parent isn't top window, bailing");
+    if (parent != sTopWindows[0])
         return NS_OK;
-    }
 
     mDirtyRegion.Or(mDirtyRegion, aRect);
     gWindowToRedraw = this;
     if (aIsSynchronous) {
         gDrawRequest = false;
         DoDraw();
     } else {
         gDrawRequest = true;
@@ -424,10 +435,11 @@ nsWindow::BringToTop()
         (*mEventCallback)(&event);
     }
 
     sTopWindows.RemoveElement(this);
     sTopWindows.InsertElementAt(0, this);
 
     nsGUIEvent event(true, NS_ACTIVATE, this);
     (*mEventCallback)(&event);
+    Update();
 }