Bug 1437941: Don't ignore mousemove after fullscreen transition r=handyman

MozReview-Commit-ID: Hr9dcKVeYEC

--HG--
extra : rebase_source : fe9d1f3526704dd5c37bcbeb7c6a62de368be12c
This commit is contained in:
Adam Gashlin 2018-04-02 18:42:12 -07:00
Родитель c1aa340b7e
Коммит cbf9e7b900
5 изменённых файлов: 34 добавлений и 27 удалений

Просмотреть файл

@ -4174,6 +4174,7 @@ FullscreenTransitionTask::Run()
this);
} else if (stage == eEnd) {
PROFILER_ADD_MARKER("Fullscreen transition end");
mWidget->CleanupFullscreenTransition();
}
return NS_OK;
}

Просмотреть файл

@ -192,6 +192,7 @@ public:
uint16_t aDuration,
nsISupports* aData,
nsIRunnable* aCallback) override;
virtual void CleanupFullscreenTransition() override {};
virtual already_AddRefed<nsIScreen> GetWidgetScreen() override;
virtual nsresult MakeFullScreen(bool aFullScreen,
nsIScreen* aScreen = nullptr) override;

Просмотреть файл

@ -1212,6 +1212,11 @@ class nsIWidget : public nsISupports
nsISupports* aData,
nsIRunnable* aCallback) = 0;
/**
* Perform any actions needed after the fullscreen transition has ended.
*/
virtual void CleanupFullscreenTransition() = 0;
/**
* Return the screen the widget is in, or null if we don't know.
*/

Просмотреть файл

@ -271,9 +271,6 @@ bool nsWindow::sHaveInitializedPrefs = false;
TriStateBool nsWindow::sHasBogusPopupsDropShadowOnMultiMonitor = TRI_UNKNOWN;
WPARAM nsWindow::sMouseExitwParam = 0;
LPARAM nsWindow::sMouseExitlParamScreen = 0;
static SystemTimeConverter<DWORD>&
TimeConverter() {
static SystemTimeConverter<DWORD> timeConverterSingleton;
@ -1965,8 +1962,6 @@ nsWindow::Resize(double aX, double aY, double aWidth,
// the system unexpectedly when we leave fullscreen state.
::SetWindowPos(mTransitionWnd, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
// Every transition window is only used once.
mTransitionWnd = nullptr;
}
SetThemeRegion();
}
@ -3441,6 +3436,7 @@ nsWindow::PrepareForFullscreenTransition(nsISupports** aData)
}
mTransitionWnd = initData.mWnd;
auto data = new FullscreenTransitionData(initData.mWnd);
*aData = data;
NS_ADDREF(data);
@ -3460,6 +3456,15 @@ nsWindow::PerformFullscreenTransition(FullscreenTransitionStage aStage,
::PostMessage(data->mWnd, msg, wparam, (LPARAM)aDuration);
}
/* virtual */ void
nsWindow::CleanupFullscreenTransition()
{
MOZ_ASSERT(NS_IsMainThread(), "CleanupFullscreenTransition "
"should only run on the main thread");
mTransitionWnd = nullptr;
}
nsresult
nsWindow::MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen)
{
@ -3509,17 +3514,6 @@ nsWindow::MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen)
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());
}
return NS_OK;
}
@ -4656,8 +4650,6 @@ nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam,
}
}
} else if (aEventMessage == eMouseExitFromWidget) {
sMouseExitwParam = wParam;
sMouseExitlParamScreen = lParamToScreen(lParam);
if (sCurrentWindow == this) {
sCurrentWindow = nullptr;
}
@ -4710,13 +4702,18 @@ void nsWindow::DispatchFocusToTopLevelWindow(bool aIsActivate)
}
}
bool nsWindow::IsTopLevelMouseExit(HWND aWnd)
HWND nsWindow::WindowAtMouse()
{
DWORD pos = ::GetMessagePos();
POINT mp;
mp.x = GET_X_LPARAM(pos);
mp.y = GET_Y_LPARAM(pos);
HWND mouseWnd = ::WindowFromPoint(mp);
return ::WindowFromPoint(mp);
}
bool nsWindow::IsTopLevelMouseExit(HWND aWnd)
{
HWND mouseWnd = WindowAtMouse();
// WinUtils::GetTopLevelHWND() will return a HWND for the window frame
// (which includes the non-client area). If the mouse has moved into
@ -5646,6 +5643,14 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
break;
mMousePresent = false;
// Check if the mouse is over the fullscreen transition window, if so
// clear sLastMouseMovePoint. This way the WM_MOUSEMOVE we get after the
// transition window disappears will not be ignored, even if the mouse
// hasn't moved.
if (mTransitionWnd && WindowAtMouse() == mTransitionWnd) {
sLastMouseMovePoint = {0};
}
// We need to check mouse button states and put them in for
// wParam.
WPARAM mouseState = (GetKeyState(VK_LBUTTON) ? MK_LBUTTON : 0)

Просмотреть файл

@ -156,6 +156,7 @@ public:
uint16_t aDuration,
nsISupports* aData,
nsIRunnable* aCallback) override;
virtual void CleanupFullscreenTransition() override;
virtual nsresult MakeFullScreen(bool aFullScreen,
nsIScreen* aScreen = nullptr) override;
virtual void HideWindowChrome(bool aShouldHide) override;
@ -493,6 +494,7 @@ protected:
* Misc.
*/
void StopFlashing();
static HWND WindowAtMouse();
static bool IsTopLevelMouseExit(HWND aWnd);
virtual nsresult SetWindowClipRegion(const nsTArray<LayoutDeviceIntRect>& aRects,
bool aIntersectWithExisting) override;
@ -672,13 +674,6 @@ protected:
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;
// Pointer events processing and management
WinPointerEvents mPointerEvents;
};