Bug 1336230 - Add suppressanimation support to Windows backend. r?jimm draft
authorMike Conley <mconley@mozilla.com>
Fri, 03 Feb 2017 17:37:37 -0500
changeset 470539 2114f193a2c7cfea8080484cea888aaffbbd205a
parent 470535 038ef2e591c522bfd39efe9d04c4515eb177bb6f
child 470540 5ed841077b6e25d714067a3bacb8cf1dc81c7ccf
push id44069
push usermconley@mozilla.com
push dateFri, 03 Feb 2017 22:51:00 +0000
reviewersjimm
bugs1336230
milestone54.0a1
Bug 1336230 - Add suppressanimation support to Windows backend. r?jimm MozReview-Commit-ID: C8aKimUBKJx
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -772,16 +772,17 @@ nsWindow::Create(nsIWidget* aParent,
     mParent = aParent;
   } else { // has a nsNative parent
     parent = (HWND)aNativeParent;
     mParent = aNativeParent ?
       WinUtils::GetNSWindowPtr((HWND)aNativeParent) : nullptr;
   }
 
   mIsRTL = aInitData->mRTL;
+  mOpeningAnimationSuppressed = aInitData->mIsAnimationSuppressed;
 
   DWORD style = WindowStyle();
   DWORD extendedStyle = WindowExStyle();
 
   if (mWindowType == eWindowType_popup) {
     if (!aParent) {
       parent = nullptr;
     }
@@ -843,16 +844,22 @@ nsWindow::Create(nsIWidget* aParent,
     return NS_ERROR_FAILURE;
   }
 
   if (mIsRTL && WinUtils::dwmSetWindowAttributePtr) {
     DWORD dwAttribute = TRUE;    
     WinUtils::dwmSetWindowAttributePtr(mWnd, DWMWA_NONCLIENT_RTL_LAYOUT, &dwAttribute, sizeof dwAttribute);
   }
 
+  if (mOpeningAnimationSuppressed && WinUtils::dwmSetWindowAttributePtr) {
+    DWORD dwAttribute = TRUE;
+    WinUtils::dwmSetWindowAttributePtr(mWnd, DWMWA_TRANSITIONS_FORCEDISABLED,
+                                       &dwAttribute, sizeof dwAttribute);
+  }
+
   if (!IsPlugin() &&
       mWindowType != eWindowType_invisible &&
       MouseScrollHandler::Device::IsFakeScrollableWindowNeeded()) {
     // Ugly Thinkpad Driver Hack (Bugs 507222 and 594977)
     //
     // We create two zero-sized windows as descendants of the top-level window,
     // like so:
     //
@@ -1617,16 +1624,22 @@ nsWindow::Show(bool bState)
 #ifdef MOZ_XUL
   if (!wasVisible && bState) {
     Invalidate();
     if (syncInvalidate && !mInDtor && !mOnDestroyCalled) {
       ::UpdateWindow(mWnd);
     }
   }
 #endif
+
+  if (mOpeningAnimationSuppressed && WinUtils::dwmSetWindowAttributePtr) {
+    DWORD dwAttribute = FALSE;
+    WinUtils::dwmSetWindowAttributePtr(mWnd, DWMWA_TRANSITIONS_FORCEDISABLED,
+                                       &dwAttribute, sizeof dwAttribute);
+  }
 }
 
 /**************************************************************
  *
  * SECTION: nsIWidget::IsVisible
  *
  * Returns the visibility state.
  *
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -527,16 +527,17 @@ protected:
   bool                  mPainting;
   bool                  mTouchWindow;
   bool                  mDisplayPanFeedback;
   bool                  mHideChrome;
   bool                  mIsRTL;
   bool                  mFullscreenMode;
   bool                  mMousePresent;
   bool                  mDestroyCalled;
+  bool                  mOpeningAnimationSuppressed;
   uint32_t              mBlurSuppressLevel;
   DWORD_PTR             mOldStyle;
   DWORD_PTR             mOldExStyle;
   nsNativeDragTarget*   mNativeDragTarget;
   HKL                   mLastKeyboardLayout;
   nsSizeMode            mOldSizeMode;
   nsSizeMode            mLastSizeMode;
   WindowHook            mWindowHook;