Windows: Fix autocapture for multiple buttons

Automatic capture of mouse events on button press was released when
the first button was released, even if multiple buttons were pressed.
Changed it so that the capture is released when the last button is
released.

Task-number: QTBUG-28007
Change-Id: Icee59aacaf0ba947820c40cb7ede00193ff46a14
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Miikka Heikkinen 2012-11-15 10:32:31 +02:00 committed by The Qt Project
parent 0a334b2180
commit aeb566db73

View File

@ -189,6 +189,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
}
QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window->handle());
const Qt::MouseButtons buttons = keyStateToMouseButtons((int)msg.wParam);
// If the window was recently resized via mouse doubleclick on the frame or title bar,
// we don't get WM_LBUTTONDOWN or WM_LBUTTONDBLCLK for the second click,
@ -199,7 +200,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
if (msg.message == WM_LBUTTONDOWN || msg.message == WM_LBUTTONDBLCLK) {
m_leftButtonDown = true;
} else {
const bool actualLeftDown = keyStateToMouseButtons((int)msg.wParam) & Qt::LeftButton;
const bool actualLeftDown = buttons & Qt::LeftButton;
if (!m_leftButtonDown && actualLeftDown) {
// Autocapture the mouse for current window to and ignore further events until release.
// Capture is necessary so we don't get WM_MOUSELEAVEs to confuse matters.
@ -236,7 +237,8 @@ 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_XBUTTONUP)) {
|| msg.message == WM_RBUTTONUP || msg.message == WM_XBUTTONUP)
&& !buttons) {
platformWindow->setMouseGrabEnabled(false);
if (QWindowsContext::verboseEvents)
qDebug() << "Releasing automatic mouse capture " << window;
@ -299,8 +301,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
m_windowUnderMouse = currentWindowUnderMouse;
}
QWindowSystemInterface::handleMouseEvent(window, winEventPosition, globalPosition,
keyStateToMouseButtons((int)msg.wParam),
QWindowSystemInterface::handleMouseEvent(window, winEventPosition, globalPosition, buttons,
QWindowsKeyMapper::queryKeyboardModifiers());
return true;
}