From b4afba0c3450fd0c14ec7bada098c4e82ca310e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 24 Mar 2023 15:26:26 +0100 Subject: [PATCH] Windows: Send synthetic mouse release after move/resize using right API The end of a move or resize might happen with the mouse still inside the non-client area of the window, in which case we correctly resolved the type to QEvent::NonClientAreaMouseButtonRelease, but we sent it via QWindowSystemInterface::handleMouseEvent, which sets nonClientArea of the event to false. This in turn resulted in QGuiApplication sending a synthetic QEvent::MouseMove in case the position was out of sync, instead of the correct QEvent::NonClientAreaMouseMove. This should really be cleaned up on the QWSI level, as there is no reason to have a dedicated API for handleFrameStrutMouseEvent, when handleMouseEvent already takes an event type, but for now we fix the immediate issue in the Windows platform plugin. Pick-to: 6.5 6.2 Change-Id: I8a831f5f19adb0625b29b50ebce9c0c6514e93f3 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowscontext.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 78fd79c0eb0..6a377c53365 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -1466,9 +1466,13 @@ void QWindowsContext::handleExitSizeMove(QWindow *window) ? 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, type, - keyboardModifiers); + if (type == QEvent::NonClientAreaMouseButtonRelease) { + QWindowSystemInterface::handleFrameStrutMouseEvent(window, localPos, globalPos, + currentButtons, button, type, keyboardModifiers); + } else { + QWindowSystemInterface::handleMouseEvent(window, localPos, globalPos, + currentButtons, button, type, keyboardModifiers); + } } } if (d->m_systemInfo & QWindowsContext::SI_SupportsPointer)