Bug 1053783 - Activate window after exiting fullscreen. r=jimm, a=sledru
authorXidorn Quan <quanxunzhen@gmail.com>
Fri, 06 Feb 2015 13:20:42 +1100
changeset 249714 c40e44bb43f10329672eb01d57d5accd8fe92739
parent 249713 c5e12814f601f4cf009f7c1465039a708960c30c
child 249715 0b04653c3d81903f99f0b68b1716b256270417f5
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm, sledru
bugs1053783
milestone37.0a2
Bug 1053783 - Activate window after exiting fullscreen. r=jimm, a=sledru
widget/windows/nsWindow.cpp
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -2865,16 +2865,18 @@ nsWindow::MakeFullScreen(bool aFullScree
     mOldSizeMode = mSizeMode;
     SetSizeMode(nsSizeMode_Fullscreen);
 
     // Notify the taskbar that we will be entering full screen mode.
     if (taskbarInfo) {
       taskbarInfo->PrepareFullScreenHWND(mWnd, TRUE);
     }
   } else {
+    if (mSizeMode != nsSizeMode_Fullscreen)
+      return NS_OK;
     SetSizeMode(mOldSizeMode);
   }
 
   UpdateNonClientMargins();
 
   bool visible = mIsVisible;
   if (mOldSizeMode == nsSizeMode_Normal)
     Show(false);
@@ -2882,16 +2884,23 @@ nsWindow::MakeFullScreen(bool aFullScree
   // Will call hide chrome, reposition window. Note this will
   // also cache dimensions for restoration, so it should only
   // be called once per fullscreen request.
   nsresult rv = nsBaseWidget::MakeFullScreen(aFullScreen, aTargetScreen);
 
   if (visible) {
     Show(true);
     Invalidate();
+
+    if (!aFullScreen && mOldSizeMode == nsSizeMode_Normal) {
+      // Ensure the window exiting fullscreen get activated. Window
+      // activation was bypassed by SetSizeMode, and hiding window for
+      // transition could also blur the current window.
+      DispatchFocusToTopLevelWindow(true);
+    }
   }
 
   // Notify the taskbar that we have exited full screen mode.
   if (!aFullScreen && taskbarInfo) {
     taskbarInfo->PrepareFullScreenHWND(mWnd, FALSE);
   }
 
   if (mWidgetListener)