From 0aafef094df29d754eae683837444e74c4465dce Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 7 Nov 2012 15:51:08 +0200 Subject: [PATCH] Windows: Add missing support for X-buttons. Autocapture and framestrut event generation didn't handle X-buttons. Task-number: QTBUG-27874 Change-Id: Icfe9dfb9abc9cd506e1875f2b2b4cbc644cff6cd Reviewed-by: Friedemann Kleint Reviewed-by: Kevin Funk --- .../platforms/windows/qwindowsmousehandler.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index c1d9362093..024a273022 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -144,6 +144,10 @@ Qt::MouseButtons QWindowsMouseHandler::queryMouseButtons() result |= mouseSwapped ? Qt::LeftButton : Qt::RightButton; if (GetAsyncKeyState(VK_MBUTTON) < 0) result |= Qt::MidButton; + if (GetAsyncKeyState(VK_XBUTTON1) < 0) + result |= Qt::XButton1; + if (GetAsyncKeyState(VK_XBUTTON2) < 0) + result |= Qt::XButton2; return result; } @@ -222,8 +226,9 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, // any button press until release. if (!platformWindow->hasMouseCapture() && (msg.message == WM_LBUTTONDOWN || msg.message == WM_MBUTTONDOWN - || msg.message == WM_RBUTTONDOWN || msg.message == WM_LBUTTONDBLCLK - || msg.message == WM_MBUTTONDBLCLK || msg.message == WM_RBUTTONDBLCLK )) { + || msg.message == WM_RBUTTONDOWN || msg.message == WM_XBUTTONDOWN + || msg.message == WM_LBUTTONDBLCLK || msg.message == WM_MBUTTONDBLCLK + || msg.message == WM_RBUTTONDBLCLK || msg.message == WM_XBUTTONDBLCLK)) { platformWindow->setMouseGrabEnabled(true); platformWindow->setFlag(QWindowsWindow::AutoMouseCapture); if (QWindowsContext::verboseEvents) @@ -231,7 +236,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, } else if (platformWindow->hasMouseCapture() && platformWindow->testFlag(QWindowsWindow::AutoMouseCapture) && (msg.message == WM_LBUTTONUP || msg.message == WM_MBUTTONUP - || msg.message == WM_RBUTTONUP)) { + || msg.message == WM_RBUTTONUP || msg.message == WM_XBUTTONUP)) { platformWindow->setMouseGrabEnabled(false); if (QWindowsContext::verboseEvents) qDebug() << "Releasing automatic mouse capture " << window;