QMdiSubWindow: Avoid potential shaking motion when moving window
When using QMouseEvent::pos to change the position of a widget, the widget may shift in a shaking motion. This is warned about in its documentation. For example if the system has a bit of load, we might receive multiple mouse move events from the OS, before QMdiSubWindow gets the first move event. In that case the first mouse move is ok, but subsequent move events, will use a ::pos value that now does not make sense as the position of the window have changed. The fix is to use QMouseEvent::globalPos. Fixes: QTBUG-72646 Change-Id: I3211cc6627ff8fe26c9520ad0457872f01c32471 Reviewed-by: Andre de la Rocha <andre.rocha@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
e85f43fd4d
commit
8b91afe12e
@ -3341,8 +3341,11 @@ void QMdiSubWindow::mouseMoveEvent(QMouseEvent *mouseEvent)
|
||||
}
|
||||
|
||||
if ((mouseEvent->buttons() & Qt::LeftButton) || d->isInInteractiveMode) {
|
||||
if ((d->isResizeOperation() && d->resizeEnabled) || (d->isMoveOperation() && d->moveEnabled))
|
||||
d->setNewGeometry(mapToParent(mouseEvent->pos()));
|
||||
if ((d->isResizeOperation() && d->resizeEnabled) || (d->isMoveOperation() && d->moveEnabled)) {
|
||||
// As setNewGeometry moves the window, it invalidates the pos() value of any mouse move events that are
|
||||
// currently queued in the event loop. Map to parent using globalPos() instead.
|
||||
d->setNewGeometry(parentWidget()->mapFromGlobal(mouseEvent->globalPos()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user