diff options
author | Andre de la Rocha <andre.rocha@qt.io> | 2018-12-13 15:54:35 +0100 |
---|---|---|
committer | Andre de la Rocha <andre.rocha@qt.io> | 2019-01-02 15:29:13 +0000 |
commit | 29ea287716175b57aa7b050b70eb3eb5c9049464 (patch) | |
tree | 404dd5711ba3f20a6b70ecdd690a093a79c8666e | |
parent | 804eea08b43d426112a5c1152f52dd3660e25b71 (diff) |
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>
-rw-r--r-- | src/plugins/platforms/windows/qwindowspointerhandler.cpp | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp index 3534f06971..78a8083d5b 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -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; } |