Bug 1235821 - Don't track mouseleave when capturing mouse. r=jimm
authorChris H-C <chutten@mozilla.com>
Wed, 06 Jan 2016 10:48:00 -0500
changeset 278916 94cd77a189810c5e1ee53b1eff5f3d4a59b07b5e
parent 278915 b1f2b22e310891548b294e2ecbe671a0d3965c57
child 278917 832653b10478c1f7f755ac3d324b4562cea3fded
push id29860
push usercbook@mozilla.com
push dateThu, 07 Jan 2016 10:51:20 +0000
treeherdermozilla-central@e0bcd16e1d4b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1235821
milestone46.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 1235821 - Don't track mouseleave when capturing mouse. r=jimm Since, in Windows, the tabbar overlays the "nonclient" area, TrackMouseEvent will report a WM_MOUSELEAVE when you move your mouse when dragging a tab. So, suspend mouseleave tracking when capturing and resume when we end capture. A nice effect of TrackMouseEvent is that it'll immediately post a WM_MOUSELEAVE if called when the mouse is outside the client area, so when capture ends, we are either over the client area and tracking resumes or we aren't and we get an immediate WM_MOUSELEAVE.
widget/windows/nsWindow.cpp
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -3380,22 +3380,29 @@ NS_METHOD nsWindow::EnableDragDrop(bool 
  * SECTION: nsIWidget::CaptureMouse
  *
  * Enables/Disables system mouse capture.
  *
  **************************************************************/
 
 NS_METHOD nsWindow::CaptureMouse(bool aCapture)
 {
+  TRACKMOUSEEVENT mTrack;
+  mTrack.cbSize = sizeof(TRACKMOUSEEVENT);
+  mTrack.dwHoverTime = 0;
+  mTrack.hwndTrack = mWnd;
   if (aCapture) {
+    mTrack.dwFlags = TME_CANCEL | TME_LEAVE;
     ::SetCapture(mWnd);
   } else {
+    mTrack.dwFlags = TME_LEAVE;
     ::ReleaseCapture();
   }
   sIsInMouseCapture = aCapture;
+  TrackMouseEvent(&mTrack);
   return NS_OK;
 }
 
 /**************************************************************
  *
  * SECTION: nsIWidget::CaptureRollupEvents
  *
  * Dealing with event rollup on destroy for popups. Enables &
@@ -5077,17 +5084,17 @@ nsWindow::ProcessMessage(UINT msg, WPARA
       if (!AutoErase((HDC)wParam)) {
         *aRetValue = 1;
         result = true;
       }
       break;
 
     case WM_MOUSEMOVE:
     {
-      if (!mMousePresent) {
+      if (!mMousePresent && !sIsInMouseCapture) {
         // First MOUSEMOVE over the client area. Ask for MOUSELEAVE
         TRACKMOUSEEVENT mTrack;
         mTrack.cbSize = sizeof(TRACKMOUSEEVENT);
         mTrack.dwFlags = TME_LEAVE;
         mTrack.dwHoverTime = 0;
         mTrack.hwndTrack = mWnd;
         TrackMouseEvent(&mTrack);
       }