Make sure mouse release events are delivered to correct widget

The initial mouse press should create an implicit mouse grab so
that all subsequent mouse events are delivered to the widget that
was pressed first. After commit a4f7bb8733, every mouse press
would reset the implicit grab. This change checks the previous
button state, and does not reset the mouse grab if other buttons
are already pressed.

Fixes: QTBUG-70816
Change-Id: Icdd215c2f4aaee3c3f34607d68c1d8878155ec17
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
bb10
Paul Olav Tvete 2018-11-05 15:56:47 +01:00 committed by Liang Qi
parent 79ed504f10
commit ac4f075274
1 changed files with 2 additions and 1 deletions

View File

@ -642,7 +642,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (!widget)
widget = m_widget;
if (event->type() == QEvent::MouseButtonPress)
const bool initialPress = event->buttons() == event->button();
if (event->type() == QEvent::MouseButtonPress && initialPress)
qt_button_down = widget;
QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(),