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 in7c3ecf85a7
. Complements4589440891
,7c3ecf85a7
. Change-Id: I8f714dc768a163878c2b4a075470bcee2dfbd802 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io> Reviewed-by: Andre de la Rocha <andre.rocha@qt.io>
This commit is contained in:
parent
b9935239db
commit
3d841556bf
@ -180,24 +180,31 @@ Qt::MouseButtons QWindowsMouseHandler::queryMouseButtons()
|
|||||||
|
|
||||||
void QWindowsMouseHandler::handleExitSizeMove(QWindow *window)
|
void QWindowsMouseHandler::handleExitSizeMove(QWindow *window)
|
||||||
{
|
{
|
||||||
// When moving a window by dragging the title bar, no WM_NCLBUTTONUP is
|
// Windows can be moved/resized by:
|
||||||
// received after WM_NCLBUTTONDOWN, WM_NCMOUSEMOVE (due to internal
|
// 1) User moving a window by dragging the title bar: Causes a sequence
|
||||||
// mouse capture), which can leave the left mouse button 'pressed'
|
// of WM_NCLBUTTONDOWN, WM_NCMOUSEMOVE but no WM_NCLBUTTONUP,
|
||||||
// in QGuiApplication's state. Intercept WM_EXITSIZEMOVE to sync the buttons.
|
// 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 currentButtons = QWindowsMouseHandler::queryMouseButtons();
|
||||||
const Qt::MouseButtons appButtons = QGuiApplication::mouseButtons();
|
const Qt::MouseButtons appButtons = QGuiApplication::mouseButtons();
|
||||||
if (currentButtons == appButtons)
|
if (currentButtons == appButtons)
|
||||||
return;
|
return;
|
||||||
const Qt::KeyboardModifiers keyboardModifiers = QWindowsKeyMapper::queryKeyboardModifiers();
|
const Qt::KeyboardModifiers keyboardModifiers = QWindowsKeyMapper::queryKeyboardModifiers();
|
||||||
const QPoint globalPos = QWindowsCursor::mousePosition();
|
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}) {
|
for (Qt::MouseButton button : {Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}) {
|
||||||
if (appButtons.testFlag(button) && !currentButtons.testFlag(button)) {
|
if (appButtons.testFlag(button) && !currentButtons.testFlag(button)) {
|
||||||
QWindowSystemInterface::handleMouseEvent(window, localPos, globalPos,
|
QWindowSystemInterface::handleMouseEvent(window, localPos, globalPos,
|
||||||
currentButtons, button,
|
currentButtons, button, type,
|
||||||
QEvent::NonClientAreaMouseButtonRelease,
|
keyboardModifiers);
|
||||||
keyboardModifiers,
|
|
||||||
Qt::MouseEventNotSynthesized);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user