Bug 1255475 - Properly distinguish 'moving' from 'resizing' state when a maximized window is dragged, resulting in a WM_SIZING message followed by WM_MOVING; this allows us to handle DPI rescaling during the move if necessary. r=emk a=ritu
authorJonathan Kew <jkew@mozilla.com>
Mon, 14 Mar 2016 18:35:59 +0000
changeset 310113 8971ca6f81ed53f66425011ddc1ccd3b310512ec
parent 310112 7f0c41c49f0e359e27d18016665dbe2b95fd13f7
child 310114 306fbf9bdddaf2290c3d51b6e19f5ada994d1863
push id9267
push userjkew@mozilla.com
push dateFri, 18 Mar 2016 07:01:50 +0000
treeherdermozilla-aurora@bf6d2a4b1031 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk, ritu
bugs1255475
milestone47.0a2
Bug 1255475 - Properly distinguish 'moving' from 'resizing' state when a maximized window is dragged, resulting in a WM_SIZING message followed by WM_MOVING; this allows us to handle DPI rescaling during the move if necessary. r=emk a=ritu
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -5362,33 +5362,31 @@ nsWindow::ProcessMessage(UINT msg, WPARA
         if (observerService) {
           observerService->NotifyObservers(nullptr, "live-resize-start",
                                            nullptr);
         }
       }
       break;
     }
 
+    case WM_MOVING:
+      FinishLiveResizing(MOVING);
+      break;
+
     case WM_ENTERSIZEMOVE:
     {
       if (mResizeState == NOT_RESIZING) {
         mResizeState = IN_SIZEMOVE;
       }
       break;
     }
 
     case WM_EXITSIZEMOVE:
     {
-      if (mResizeState == RESIZING) {
-        nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
-        if (observerService) {
-          observerService->NotifyObservers(nullptr, "live-resize-end", nullptr);
-        }
-      }
-      mResizeState = NOT_RESIZING;
+      FinishLiveResizing(NOT_RESIZING);
 
       if (!sIsInMouseCapture) {
         NotifySizeMoveDone();
       }
 
       break;
     }
 
@@ -5772,16 +5770,28 @@ nsWindow::ProcessMessage(UINT msg, WPARA
   }
   else {
     //Events which caused mWnd destruction and aren't consumed
     //will crash during the Windows default processing.
     return true;
   }
 }
 
+void
+nsWindow::FinishLiveResizing(ResizeState aNewState)
+{
+  if (mResizeState == RESIZING) {
+    nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
+    if (observerService) {
+      observerService->NotifyObservers(nullptr, "live-resize-end", nullptr);
+    }
+  }
+  mResizeState = aNewState;
+}
+
 /**************************************************************
  *
  * SECTION: Broadcast messaging
  *
  * Broadcast messages to all windows.
  *
  **************************************************************/
 
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -319,16 +319,24 @@ protected:
 
   virtual nsresult NotifyIMEInternal(
                      const IMENotification& aIMENotification) override;
 
   // A magic number to identify the FAKETRACKPOINTSCROLLABLE window created
   // when the trackpoint hack is enabled.
   enum { eFakeTrackPointScrollableID = 0x46545053 };
 
+  // Used for displayport suppression during window resize
+  enum ResizeState {
+    NOT_RESIZING,
+    IN_SIZEMOVE,
+    RESIZING,
+    MOVING
+  };
+
   /**
    * Callbacks
    */
   static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
   static LRESULT CALLBACK WindowProcInternal(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
 
   static BOOL CALLBACK    BroadcastMsgToChildren(HWND aWnd, LPARAM aMsg);
   static BOOL CALLBACK    BroadcastMsg(HWND aTopWindow, LPARAM aMsg);
@@ -396,16 +404,17 @@ protected:
                                                 bool *aEventDispatched);
   static bool             EventIsInsideWindow(nsWindow* aWindow);
   // Convert nsEventStatus value to a windows boolean
   static bool             ConvertStatus(nsEventStatus aStatus);
   static void             PostSleepWakeNotification(const bool aIsSleepMode);
   int32_t                 ClientMarginHitTestPoint(int32_t mx, int32_t my);
   TimeStamp               GetMessageTimeStamp(LONG aEventTime);
   static void             UpdateFirstEventTime(DWORD aEventTime);
+  void                    FinishLiveResizing(ResizeState aNewState);
 
   /**
    * Event handlers
    */
   virtual void            OnDestroy() override;
   virtual bool            OnResize(nsIntRect &aWindowRect);
   bool                    OnGesture(WPARAM wParam, LPARAM lParam);
   bool                    OnTouch(WPARAM wParam, LPARAM lParam);
@@ -579,22 +588,16 @@ protected:
   static BYTE           sLastMouseButton;
 
   // Graphics
   HDC                   mPaintDC; // only set during painting
   HDC                   mCompositeDC; // only set during StartRemoteDrawing
 
   LayoutDeviceIntRect   mLastPaintBounds;
 
-  // Used for displayport suppression during window resize
-  enum ResizeState {
-    NOT_RESIZING,
-    IN_SIZEMOVE,
-    RESIZING,
-  };
   ResizeState mResizeState;
 
   // Transparency
 #ifdef MOZ_XUL
   // Use layered windows to support full 256 level alpha translucency
   RefPtr<gfxASurface> mTransparentSurface;
   HDC                   mMemoryDC;
   nsTransparencyMode    mTransparencyMode;