diff options
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsmousehandler.cpp')
-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); } } } |