Windows QPA: Avoid duplication of mouse events

The code being removed was added as a workaround to support the use of
QCursor::setPos() with unit tests. This function was used to move
the Windows mouse cursor, internally calling SetCursorPos(), which
generates only WM_MOUSE* messages, bypassing the pointer messages.
However, the workaround had the unintended effect of generating
duplicated mouse events for normal mouse movement, which caused issues
like the one described by QTBUG-70974. However, it seems the tests are
no longer depending on it, allowing it to be removed.

Fixes: QTBUG-70974
Change-Id: Iaf0d64c73951ab1b660e9bb90e7ee009e53fbd3a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
bb10
Andre de la Rocha 2018-12-13 15:54:35 +01:00
parent 804eea08b4
commit 29ea287716
1 changed files with 0 additions and 29 deletions

View File

@ -370,22 +370,6 @@ static Qt::MouseButtons mouseButtonsFromPointerFlags(POINTER_FLAGS pointerFlags)
return result;
}
static Qt::MouseButtons mouseButtonsFromKeyState(WPARAM keyState)
{
Qt::MouseButtons result = Qt::NoButton;
if (keyState & MK_LBUTTON)
result |= Qt::LeftButton;
if (keyState & MK_RBUTTON)
result |= Qt::RightButton;
if (keyState & MK_MBUTTON)
result |= Qt::MiddleButton;
if (keyState & MK_XBUTTON1)
result |= Qt::XButton1;
if (keyState & MK_XBUTTON2)
result |= Qt::XButton2;
return result;
}
static QWindow *getWindowUnderPointer(QWindow *window, QPoint globalPos)
{
QWindow *currentWindowUnderPointer = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT);
@ -816,14 +800,6 @@ bool QWindowsPointerHandler::translateMouseEvent(QWindow *window, HWND hwnd, QtW
return false;
}
// Windows sends a mouse move with no buttons pressed to signal "Enter"
// when a window is shown over the cursor. Discard the event and only use
// it for generating QEvent::Enter to be consistent with other platforms -
// X11 and macOS.
static QPoint lastMouseMovePos;
const bool discardEvent = msg.wParam == 0 && (m_windowUnderPointer.isNull() || globalPos == lastMouseMovePos);
lastMouseMovePos = globalPos;
QWindow *currentWindowUnderPointer = getWindowUnderPointer(window, globalPos);
if (currentWindowUnderPointer != m_windowUnderPointer) {
@ -846,11 +822,6 @@ bool QWindowsPointerHandler::translateMouseEvent(QWindow *window, HWND hwnd, QtW
m_windowUnderPointer = currentWindowUnderPointer;
}
const Qt::MouseButtons mouseButtons = mouseButtonsFromKeyState(msg.wParam);
if (!discardEvent)
QWindowSystemInterface::handleMouseEvent(window, localPos, globalPos, mouseButtons, Qt::NoButton, QEvent::MouseMove,
keyModifiers, Qt::MouseEventNotSynthesized);
return false;
}