зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1549972
- Use ClientMarginHitTestPoint when checking if the mouse is within a draggable region. r=jmathies
ClientMarginHitTestPoint takes into account the fact that we want a minimum of kResizableBorderMinSize pixels thickness around the window to trigger resizing. Differential Revision: https://phabricator.services.mozilla.com/D30427 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
3ffe3911b3
Коммит
13db7ce890
|
@ -615,7 +615,7 @@ nsWindow::nsWindow(bool aIsChildWindow)
|
|||
mCachedHitTestPoint.x = 0;
|
||||
mCachedHitTestPoint.y = 0;
|
||||
mCachedHitTestTime = TimeStamp::Now();
|
||||
mCachedHitTestResult = false;
|
||||
mCachedHitTestResult = 0;
|
||||
#ifdef MOZ_XUL
|
||||
mTransparencyMode = eTransparencyOpaque;
|
||||
memset(&mGlassMargins, 0, sizeof mGlassMargins);
|
||||
|
@ -5312,8 +5312,10 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
|
|||
break;
|
||||
|
||||
case WM_MOUSEMOVE: {
|
||||
mMouseInDraggableArea =
|
||||
WithinDraggableRegion(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
LPARAM lParamScreen = lParamToScreen(lParam);
|
||||
mMouseInDraggableArea = WithinDraggableRegion(GET_X_LPARAM(lParamScreen),
|
||||
GET_Y_LPARAM(lParamScreen));
|
||||
|
||||
if (!mMousePresent && !sIsInMouseCapture) {
|
||||
// First MOUSEMOVE over the client area. Ask for MOUSELEAVE
|
||||
TRACKMOUSEEVENT mTrack;
|
||||
|
@ -5328,7 +5330,6 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
|
|||
// Suppress dispatch of pending events
|
||||
// when mouse moves are generated by widget
|
||||
// creation instead of user input.
|
||||
LPARAM lParamScreen = lParamToScreen(lParam);
|
||||
POINT mp;
|
||||
mp.x = GET_X_LPARAM(lParamScreen);
|
||||
mp.y = GET_Y_LPARAM(lParamScreen);
|
||||
|
@ -5348,8 +5349,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
|
|||
|
||||
case WM_NCMOUSEMOVE: {
|
||||
LPARAM lParamClient = lParamToClient(lParam);
|
||||
if (WithinDraggableRegion(GET_X_LPARAM(lParamClient),
|
||||
GET_Y_LPARAM(lParamClient))) {
|
||||
if (WithinDraggableRegion(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
|
||||
// If we noticed the mouse moving in our draggable region, forward the
|
||||
// message as a normal WM_MOUSEMOVE.
|
||||
SendMessage(mWnd, WM_MOUSEMOVE, 0, lParamClient);
|
||||
|
@ -6163,27 +6163,29 @@ int32_t nsWindow::ClientMarginHitTestPoint(int32_t mx, int32_t my) {
|
|||
if (!sIsInMouseCapture && allowContentOverride) {
|
||||
POINT pt = {mx, my};
|
||||
::ScreenToClient(mWnd, &pt);
|
||||
if (WithinDraggableRegion(pt.x, pt.y)) {
|
||||
|
||||
if (pt.x == mCachedHitTestPoint.x && pt.y == mCachedHitTestPoint.y &&
|
||||
TimeStamp::Now() - mCachedHitTestTime <
|
||||
TimeDuration::FromMilliseconds(HITTEST_CACHE_LIFETIME_MS)) {
|
||||
return mCachedHitTestResult;
|
||||
}
|
||||
|
||||
mCachedHitTestPoint = {pt.x, pt.y};
|
||||
mCachedHitTestTime = TimeStamp::Now();
|
||||
|
||||
if (mDraggableRegion.Contains(pt.x, pt.y)) {
|
||||
testResult = HTCAPTION;
|
||||
} else {
|
||||
testResult = HTCLIENT;
|
||||
}
|
||||
mCachedHitTestResult = testResult;
|
||||
}
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
bool nsWindow::WithinDraggableRegion(int32_t clientX, int32_t clientY) {
|
||||
if (clientX == mCachedHitTestPoint.x && clientY == mCachedHitTestPoint.y &&
|
||||
TimeStamp::Now() - mCachedHitTestTime <
|
||||
TimeDuration::FromMilliseconds(HITTEST_CACHE_LIFETIME_MS)) {
|
||||
return mCachedHitTestResult;
|
||||
}
|
||||
mCachedHitTestPoint = {clientX, clientY};
|
||||
mCachedHitTestTime = TimeStamp::Now();
|
||||
|
||||
mCachedHitTestResult = mDraggableRegion.Contains(clientX, clientY);
|
||||
return mCachedHitTestResult;
|
||||
bool nsWindow::WithinDraggableRegion(int32_t screenX, int32_t screenY) {
|
||||
return ClientMarginHitTestPoint(screenX, screenY) == HTCAPTION;
|
||||
}
|
||||
|
||||
TimeStamp nsWindow::GetMessageTimeStamp(LONG aEventTime) const {
|
||||
|
|
|
@ -664,7 +664,7 @@ class nsWindow final : public nsWindowBase {
|
|||
// Whether we we're created as a child window (aka ChildWindow) or not.
|
||||
bool mIsChildWindow : 1;
|
||||
|
||||
bool mCachedHitTestResult;
|
||||
int32_t mCachedHitTestResult;
|
||||
|
||||
// The point in time at which the last paint completed. We use this to avoid
|
||||
// painting too rapidly in response to frequent input events.
|
||||
|
|
Загрузка…
Ссылка в новой задаче