Bug 580564 - Fix for broken alt-space sys menu restore when in full screen mode. r=neil
authorJim Mathies <jmathies@mozilla.com>
Fri, 27 May 2011 17:35:45 -0500
changeset 70263 dc1077c0954099bddf4861e20d3ade741c756e33
parent 70262 3b2ad265faf185dabe80f42e861c1b6437b31064
child 70264 147bc646bcaa0b792e297e59ddf46b6a6b9ccad6
child 71430 bf38817fa20a723c07b8e841edd4d913340da8e4
push id20262
push userjmathies@mozilla.com
push dateFri, 27 May 2011 22:36:01 +0000
treeherdermozilla-central@dc1077c09540 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil
bugs580564
milestone7.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 580564 - Fix for broken alt-space sys menu restore when in full screen mode. r=neil
widget/src/windows/nsWindow.cpp
xpfe/appshell/src/nsWebShellWindow.cpp
xpfe/appshell/src/nsWebShellWindow.h
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -4303,17 +4303,16 @@ DisplaySystemMenu(HWND hWnd, nsSizeMode 
     SetMenuItemInfo(hMenu, SC_SIZE, FALSE, &mii);
     SetMenuItemInfo(hMenu, SC_MOVE, FALSE, &mii);
     SetMenuItemInfo(hMenu, SC_MAXIMIZE, FALSE, &mii);
     SetMenuItemInfo(hMenu, SC_MINIMIZE, FALSE, &mii);
 
     mii.fState = MF_GRAYED;
     switch(sizeMode) {
       case nsSizeMode_Fullscreen:
-        SetMenuItemInfo(hMenu, SC_RESTORE, FALSE, &mii);
         // intentional fall through
       case nsSizeMode_Maximized:
         SetMenuItemInfo(hMenu, SC_SIZE, FALSE, &mii);
         SetMenuItemInfo(hMenu, SC_MOVE, FALSE, &mii);
         SetMenuItemInfo(hMenu, SC_MAXIMIZE, FALSE, &mii);
         break;
       case nsSizeMode_Minimized:
         SetMenuItemInfo(hMenu, SC_MINIMIZE, FALSE, &mii);
@@ -5223,16 +5222,23 @@ PRBool nsWindow::ProcessMessage(UINT msg
       // so we can set the appropriate options.
       if (filteredWParam == SC_KEYMENU && lParam == VK_SPACE &&
           mSizeMode == nsSizeMode_Fullscreen) {
         DisplaySystemMenu(mWnd, mSizeMode, mIsRTL,
                           MOZ_SYSCONTEXT_X_POS,
                           MOZ_SYSCONTEXT_Y_POS);
         result = PR_TRUE;
       }
+      if (filteredWParam == SC_RESTORE &&
+          mSizeMode == nsSizeMode_Fullscreen) {
+        // Windows can handle restoring a normal window, but it doesn't
+        // understand our full screen mode.
+        MakeFullScreen(PR_FALSE);
+        result = PR_TRUE;
+      }
     }
     break;
 
   case WM_MOUSEWHEEL:
   case WM_MOUSEHWHEEL:
     {
       // If OnMouseWheel returns true, the event was forwarded directly to another
       // mozilla window message handler (ProcessMessage). In this case the return
--- a/xpfe/appshell/src/nsWebShellWindow.cpp
+++ b/xpfe/appshell/src/nsWebShellWindow.cpp
@@ -120,16 +120,17 @@ using namespace mozilla;
 /* Define Class IDs */
 static NS_DEFINE_CID(kWindowCID,           NS_WINDOW_CID);
 
 #define SIZE_PERSISTENCE_TIMEOUT 500 // msec
 
 nsWebShellWindow::nsWebShellWindow(PRUint32 aChromeFlags)
   : nsXULWindow(aChromeFlags)
   , mSPTimerLock("nsWebShellWindow.mSPTimerLock")
+  , mSizeMode(-1)
 {
 }
 
 
 nsWebShellWindow::~nsWebShellWindow()
 {
   if (mWindow) {
     mWindow->SetClientData(0);
@@ -380,22 +381,25 @@ nsWebShellWindow::HandleEvent(nsGUIEvent
         // cases this will merge with the similar call in NS_SIZE and
         // write the attribute values only once.
         eventWindow->SetPersistenceTimer(PAD_MISC);
         result = nsEventStatus_eConsumeDoDefault;
 
         // min, max, and normal are all the same to apps, but for
         // fullscreen we need to let them know so they can update
         // their ui. 
-        if (modeEvent->mSizeMode == nsSizeMode_Fullscreen) {
+        if (modeEvent->mSizeMode == nsSizeMode_Fullscreen ||
+            eventWindow->mSizeMode == nsSizeMode_Fullscreen) {
           nsCOMPtr<nsIDOMWindowInternal> ourWindow = do_GetInterface(docShell);
           if (ourWindow)
-            ourWindow->SetFullScreen(PR_TRUE);
+            ourWindow->SetFullScreen(modeEvent->mSizeMode == nsSizeMode_Fullscreen);
         }
 
+        eventWindow->mSizeMode = modeEvent->mSizeMode;
+
         // Note the current implementation of SetSizeMode just stores
         // the new state; it doesn't actually resize. So here we store
         // the state and pass the event on to the OS. The day is coming
         // when we'll handle the event here, and the return result will
         // then need to be different.
         break;
       }
       case NS_OS_TOOLBAR: {
--- a/xpfe/appshell/src/nsWebShellWindow.h
+++ b/xpfe/appshell/src/nsWebShellWindow.h
@@ -86,15 +86,16 @@ protected:
   void                     LoadContentAreas();
   PRBool                   ExecuteCloseHandler();
   void                     ConstrainToOpenerScreen(PRInt32* aX, PRInt32* aY);
 
   static nsEventStatus HandleEvent(nsGUIEvent *aEvent);
 
   nsCOMPtr<nsITimer>      mSPTimer;
   mozilla::Mutex          mSPTimerLock;
+  PRInt32                 mSizeMode;
 
   void        SetPersistenceTimer(PRUint32 aDirtyFlags);
   static void FirePersistenceTimer(nsITimer *aTimer, void *aClosure);
 };
 
 
 #endif /* nsWebShellWindow_h__ */