diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-05-30 10:27:03 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-05-31 14:41:06 +0000 |
commit | 3d841556bf4b01cd0a2831a191163f0c19ef15e8 (patch) | |
tree | ac1120b4973dde33b56712e91d5ed9a1e2a39e24 /src/plugins/platforms/windows | |
parent | b9935239db277655240d1db177ea41a269fd5ea1 (diff) |
Windows QPA: Fix release button event type after moving windows
Check whether the mouse is inside the window and report
MouseButtonRelease or QEvent::NonClientAreaMouseButtonRelease,
respectively. The inside case is triggered by programmatically
starting a size move via QPlatformWindow::startSystemResize()
(QSizeGrip) and was overlooked in
7c3ecf85a770cd7fef01ece935f88d8894de09b2.
Complements 45894408913f62f6f25a302d8ed07af57ac7db5d,
7c3ecf85a770cd7fef01ece935f88d8894de09b2.
Change-Id: I8f714dc768a163878c2b4a075470bcee2dfbd802
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Reviewed-by: Andre de la Rocha <andre.rocha@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsmousehandler.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index bec935cd80..add01f65cc 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -180,24 +180,31 @@ Qt::MouseButtons QWindowsMouseHandler::queryMouseButtons() void QWindowsMouseHandler::handleExitSizeMove(QWindow *window) { - // When moving a window by dragging the title bar, no WM_NCLBUTTONUP is - // received after WM_NCLBUTTONDOWN, WM_NCMOUSEMOVE (due to internal - // mouse capture), which can leave the left mouse button 'pressed' - // in QGuiApplication's state. Intercept WM_EXITSIZEMOVE to sync the buttons. + // Windows can be moved/resized by: + // 1) User moving a window by dragging the title bar: Causes a sequence + // of WM_NCLBUTTONDOWN, WM_NCMOUSEMOVE but no WM_NCLBUTTONUP, + // leaving the left mouse button 'pressed' + // 2) User choosing Resize/Move from System menu and using mouse/cursor keys: + // No mouse events are received + // 3) Programmatically via QSizeGrip calling QPlatformWindow::startSystemResize/Move(): + // Mouse is left in pressed state after press on size grip (inside window), + // no further mouse events are received + // For cases 1,3, intercept WM_EXITSIZEMOVE to sync the buttons. const Qt::MouseButtons currentButtons = QWindowsMouseHandler::queryMouseButtons(); const Qt::MouseButtons appButtons = QGuiApplication::mouseButtons(); if (currentButtons == appButtons) return; const Qt::KeyboardModifiers keyboardModifiers = QWindowsKeyMapper::queryKeyboardModifiers(); const QPoint globalPos = QWindowsCursor::mousePosition(); - const QPoint localPos = window->handle()->mapFromGlobal(globalPos); + const QPlatformWindow *platWin = window->handle(); + const QPoint localPos = platWin->mapFromGlobal(globalPos); + const QEvent::Type type = platWin->geometry().contains(globalPos) + ? QEvent::MouseButtonRelease : QEvent::NonClientAreaMouseButtonRelease; for (Qt::MouseButton button : {Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}) { if (appButtons.testFlag(button) && !currentButtons.testFlag(button)) { QWindowSystemInterface::handleMouseEvent(window, localPos, globalPos, - currentButtons, button, - QEvent::NonClientAreaMouseButtonRelease, - keyboardModifiers, - Qt::MouseEventNotSynthesized); + currentButtons, button, type, + keyboardModifiers); } } } |