Bug 1273091 - Mouse cursor does not disappear in html5 fullscreen video on Windows. r=masayuki a=jcristau a=gchang
authorDavid Parks <dparks@mozilla.com>
Mon, 28 Nov 2016 10:46:15 -0800
changeset 352942 ee5a46acf5cec8b56d348c3b4605f309e7846f79
parent 352941 b512f512ba1fd814530bd77a048194ba0ed8399c
child 352943 2af052da30319a9210711bc5d7180e63c03161ac
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki, jcristau, gchang
bugs1273091
milestone52.0a2
Bug 1273091 - Mouse cursor does not disappear in html5 fullscreen video on Windows. r=masayuki a=jcristau a=gchang When we jump to fullscreen, the OS sends a WM_MOUSELEAVE, which we turn into a eMouseExitFromWidget. The eMouseEnterIntoWidget was previously only sent when the mouse moved into the widget, which required the mouse to move. When entering fullscreen, we want the eMouseEnterIntoWidget to happen right away.
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -265,16 +265,19 @@ LONG            nsWindow::sLastMouseDown
 LONG            nsWindow::sLastClickCount         = 0L;
 BYTE            nsWindow::sLastMouseButton        = 0;
 
 // Trim heap on minimize. (initialized, but still true.)
 int             nsWindow::sTrimOnMinimize         = 2;
 
 TriStateBool nsWindow::sHasBogusPopupsDropShadowOnMultiMonitor = TRI_UNKNOWN;
 
+WPARAM nsWindow::sMouseExitwParam = 0;
+LPARAM nsWindow::sMouseExitlParamScreen = 0;
+
 static SystemTimeConverter<DWORD>&
 TimeConverter() {
   static SystemTimeConverter<DWORD> timeConverterSingleton;
   return timeConverterSingleton;
 }
 
 namespace mozilla {
 
@@ -3266,16 +3269,27 @@ nsWindow::MakeFullScreen(bool aFullScree
     taskbarInfo->PrepareFullScreenHWND(mWnd, FALSE);
   }
 
   if (mWidgetListener) {
     mWidgetListener->SizeModeChanged(mSizeMode);
     mWidgetListener->FullscreenChanged(aFullScreen);
   }
 
+  // Send a eMouseEnterIntoWidget event since Windows has already sent
+  // a WM_MOUSELEAVE that caused us to send a eMouseExitFromWidget event.
+  if (aFullScreen && !sCurrentWindow) {
+    sCurrentWindow = this;
+    LPARAM pos = sCurrentWindow->lParamToClient(sMouseExitlParamScreen);
+    sCurrentWindow->DispatchMouseEvent(eMouseEnterIntoWidget,
+                                       sMouseExitwParam, pos, false,
+                                       WidgetMouseEvent::eLeftButton,
+                                       MOUSE_INPUT_SOURCE(), MOUSE_POINTERID());
+  }
+
   return NS_OK;
 }
 
 /**************************************************************
  *
  * SECTION: Native data storage
  *
  * nsIWidget::GetNativeData
@@ -4244,16 +4258,18 @@ nsWindow::DispatchMouseEvent(EventMessag
             sCurrentWindow->DispatchMouseEvent(eMouseEnterIntoWidget,
                                                wParam, pos, false,
                                                WidgetMouseEvent::eLeftButton,
                                                aInputSource, aPointerId);
           }
         }
       }
     } else if (aEventMessage == eMouseExitFromWidget) {
+      sMouseExitwParam = wParam;
+      sMouseExitlParamScreen = lParamToScreen(lParam);
       if (sCurrentWindow == this) {
         sCurrentWindow = nullptr;
       }
     }
 
     result = ConvertStatus(DispatchInputEvent(&event));
 
     // Release the widget with NS_IF_RELEASE() just in case
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -642,16 +642,23 @@ protected:
   int32_t mCachedHitTestResult;
 
   RefPtr<mozilla::widget::WinCompositorWidget> mBasicLayersSurface;
 
   static bool sNeedsToInitMouseWheelSettings;
   static void InitMouseWheelScrollData();
 
   double mSizeConstraintsScale; // scale in effect when setting constraints
+
+  // Used to remember the wParam (i.e. currently pressed modifier keys)
+  // and lParam (i.e. last mouse position) in screen coordinates from
+  // the previous mouse-exit.  Static since it is not
+  // associated with a particular widget (since we exited the widget).
+  static WPARAM sMouseExitwParam;
+  static LPARAM sMouseExitlParamScreen;
 };
 
 /**
  * A child window is a window with different style.
  */
 class ChildWindow : public nsWindow {
 
 public: