Bug 581697 - During processing of NS_SIZEMODE events, skip the call to `::ShowWindow` if we're restoring a window that is already restored; r=jmathies
authorTim Abraldes <tabraldes@mozilla.com>
Thu, 28 Jul 2011 17:47:47 -0500
changeset 73523 567a0c458ae00e8002368e0ea8eace49141924d6
parent 73522 524a9852f99ff258b965a0bc29391dd32923629a
child 73524 eaf738a0e1b331e72aad1941425860af311c9824
push id20884
push usermak77@bonardo.net
push dateFri, 29 Jul 2011 09:49:02 +0000
treeherdermozilla-central@f5f1e3822540 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmathies
bugs581697
milestone8.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 581697 - During processing of NS_SIZEMODE events, skip the call to `::ShowWindow` if we're restoring a window that is already restored; r=jmathies
widget/src/windows/nsWindow.cpp
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -1660,17 +1660,27 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRIn
         // If sTrimOnMinimize is set, we let windows handle minimization normally
         // using SW_MINIMIZE.
         mode = sTrimOnMinimize ? SW_MINIMIZE : SW_SHOWMINIMIZED;
         break;
 
       default :
         mode = SW_RESTORE;
     }
-    ::ShowWindow(mWnd, mode);
+
+    WINDOWPLACEMENT pl;
+    pl.length = sizeof(pl);
+    ::GetWindowPlacement(mWnd, &pl);
+    // Don't call ::ShowWindow if we're trying to "restore" a window that is
+    // already in a normal state.  Prevents a bug where snapping to one side
+    // of the screen and then minimizing would cause Windows to forget our
+    // window's correct restored position/size.
+    if( !(pl.showCmd == SW_SHOWNORMAL && mode == SW_RESTORE) ) {
+      ::ShowWindow(mWnd, mode);
+    }
     // we dispatch an activate event here to ensure that the right child window
     // is focused
     if (mode == SW_RESTORE || mode == SW_MAXIMIZE || mode == SW_SHOW)
       DispatchFocusToTopLevelWindow(NS_ACTIVATE);
   }
   return rv;
 }