Fix key modifiers in mouse wheel events on Windows.
authorGlenn Watson <glenn.watson@nokia.com>
Fri, 22 Jun 2012 00:36:36 +0000 (10:36 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 22 Jun 2012 09:47:24 +0000 (11:47 +0200)
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 <martin.jones@nokia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
src/plugins/platforms/windows/qwindowsmousehandler.cpp
src/plugins/platforms/windows/qwindowsmousehandler.h

index 48d4385..eb7d291 100644 (file)
@@ -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;
 }
 
index b3d176d..a978840 100644 (file)
@@ -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;