From 200c6dd896c13cf86dbf25842f3839c49cff226d Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Fri, 27 Oct 2017 14:19:03 +0200 Subject: qwidgetwindow: remove seemingly stray QApplicationPrivate::mouse_buttons This patch removes mouse_buttons related code from qwidgetwindow.cpp as it does not belong there for the following reasons: - The commit (ed2a2dc6dae0a2523cecfd272609d322ace16145) that added it in Qt5 says that the logic was copied from qapplication_x11.cpp (filename in Qt4 repository). Other qapplication_*.cpp platform implementations did not have this kind of logic; thus having it in cross platform location qwidgetwindow.cpp does not make sense. - According to the documentation, QApplicationPrivate::mouse_buttons: "Returns the current state of the buttons on the mouse. The current state is updated synchronously as the event queue is emptied". So the only place where changing this variable makes sense is in QGuiApplicationPrivate::processMouseEvent, which is *when the event queue is emptied*. There are other places in source code where this variable is changed, but all of those are hacks and should be cleaned out eventually: // a hack due to insufficient QWindowSystemInterface API plugins/platforms/windows/qwindowsdrag.cpp // a hack to support code that bypasses QWSI API when sending mouse events // via qApp->notify(). widgets/kernel/qapplication.cpp - AFACT, the released button bit will be already unset by the time mouse release event reaches QWidgetWindow::handleMouseEvent. Change-Id: Ifb2b3b443ffff0274545e5d3c631cf1e77160502 Reviewed-by: Frederik Gladhorn --- src/widgets/kernel/qwidgetwindow.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 80ed39bf76..2b703e8ff2 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -633,12 +633,9 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(), qt_button_down, widget); - - if (!receiver) { - if (event->type() == QEvent::MouseButtonRelease) - QApplicationPrivate::mouse_buttons &= ~event->button(); + if (!receiver) return; - } + if ((event->type() != QEvent::MouseButtonPress) || !(event->flags().testFlag(Qt::MouseEventCreatedDoubleClick))) { -- cgit v1.2.3