From 4a8d9eed87565b20c1f10b173c652be26ea608f7 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Fri, 22 Jun 2012 10:36:36 +1000 Subject: [PATCH] Fix key modifiers in mouse wheel events on Windows. The Windows platform plugin was not checking for the control or shift keyboard modifiers when processing mouse wheel events. Added a function to convert Windows wheel events to Qt::KeyboardModifiers and passed this through the event chain. Task-number: QTBUG-25754 Change-Id: I6551e98b4eaebad5704058bddfb06502ded5155d Reviewed-by: Martin Jones Reviewed-by: Friedemann Kleint --- .../platforms/windows/qwindowsmousehandler.cpp | 4 +++- src/plugins/platforms/windows/qwindowsmousehandler.h | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 48d43857e9..eb7d2912bb 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -196,6 +196,8 @@ bool QWindowsMouseHandler::translateMouseWheelEvent(QWindow *window, HWND, MSG msg, LRESULT *) { const Qt::MouseButtons buttons = keyStateToMouseButtons((int)msg.wParam); + const Qt::KeyboardModifiers mods = keyStateToModifiers((int)msg.wParam); + int delta; if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL) delta = (short) HIWORD (msg.wParam); @@ -224,7 +226,7 @@ bool QWindowsMouseHandler::translateMouseWheelEvent(QWindow *window, HWND, QWindowSystemInterface::handleWheelEvent(receiver, QWindowsGeometryHint::mapFromGlobal(receiver, globalPos), globalPos, - delta, orientation); + delta, orientation, mods); return true; } diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.h b/src/plugins/platforms/windows/qwindowsmousehandler.h index b3d176db9b..a978840d67 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.h +++ b/src/plugins/platforms/windows/qwindowsmousehandler.h @@ -67,6 +67,7 @@ public: LRESULT *result); static inline Qt::MouseButtons keyStateToMouseButtons(int); + static inline Qt::KeyboardModifiers keyStateToModifiers(int); static inline int mouseButtonsToKeyState(Qt::MouseButtons); QWindow *windowUnderMouse() const { return m_windowUnderMouse.data(); } @@ -96,6 +97,16 @@ Qt::MouseButtons QWindowsMouseHandler::keyStateToMouseButtons(int wParam) return mb; } +Qt::KeyboardModifiers QWindowsMouseHandler::keyStateToModifiers(int wParam) +{ + Qt::KeyboardModifiers mods(Qt::NoModifier); + if (wParam & MK_CONTROL) + mods |= Qt::ControlModifier; + if (wParam & MK_SHIFT) + mods |= Qt::ShiftModifier; + return mods; +} + int QWindowsMouseHandler::mouseButtonsToKeyState(Qt::MouseButtons mb) { int result = 0;