From: Friedemann Kleint Date: Thu, 6 Sep 2012 12:37:59 +0000 (+0200) Subject: Revert "Implement automatic mouse grabbing on mouse button press." X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=75cd2dec71d81868e1c4d5df32eb602faeb165fc;p=profile%2Fivi%2Fqtbase.git Revert "Implement automatic mouse grabbing on mouse button press." This reverts commit 6b5bbc531b30d8ece25425e39843c6ae1af1d045. Autograbbing mouse shouldn't be done in crossplatform code, as X11 does this automatically. Windows needs platform specific solution. Task-number: QTBUG-26962 Task-number: QTBUG-27039 Task-number: QTBUG-23699 Change-Id: I911df92c4a34deb50b729f50681497046657948b Reviewed-by: Miikka Heikkinen Reviewed-by: Friedemann Kleint --- diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 9d1b9c9..34b2893 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3135,8 +3135,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) d->toolTipGlobalPos = mouse->globalPos(); d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive()?20:700, this); } - - d->handleAutomaticMouseGrab(w, mouse); } bool eventAccepted = mouse->isAccepted(); diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index a779c29..be88e2c 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -166,7 +166,6 @@ public: void openPopup(QWidget *popup); static void setFocusWidget(QWidget *focus, Qt::FocusReason reason); static QWidget *focusNextPrevChild_helper(QWidget *toplevel, bool next); - void handleAutomaticMouseGrab(QWidget *widget, QMouseEvent *e); #ifndef QT_NO_SESSIONMANAGER QSessionManager *session_manager; diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index 0afc208..76e160b 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -72,8 +72,7 @@ QT_BEGIN_NAMESPACE static QString appFont; -static bool popupGrabOk = false; -static QPointer autoGrabber; +static bool popupGrabOk; extern QWidget *qt_button_down; extern QWidget *qt_popup_down; extern bool qt_replay_popup_mouse_event; @@ -142,28 +141,6 @@ void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous) QApplication::setActiveWindow(tlw); } -void QApplicationPrivate::handleAutomaticMouseGrab(QWidget *widget, QMouseEvent *e) -{ - // Grab the mouse automatically for current window when any button is pressed, - // unless there is an active mousegrabber or mouse is being grabbed for a popup. - if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonRelease) { - if (e->buttons() == Qt::NoButton) { - // No buttons remain pressed, so release the grab unless grab has been acquired - // for some other reason in the meantime. - if (autoGrabber && !QWidget::mouseGrabber() && !popupGrabOk) - qt_widget_private(autoGrabber)->stealMouseGrab(false); - autoGrabber = 0; - } else { - // Some buttons are pressed, grab mouse input for current window, - // unless there is already an active grab. - if (!autoGrabber && !QWidget::mouseGrabber() && !popupGrabOk) { - autoGrabber = widget->window(); - qt_widget_private(autoGrabber)->stealMouseGrab(true); - } - } - } -} - static void ungrabKeyboardForPopup(QWidget *popup) { if (QWidget::keyboardGrabber()) @@ -185,9 +162,6 @@ static void grabForPopup(QWidget *popup) Q_ASSERT(popup->testAttribute(Qt::WA_WState_Created)); popupGrabOk = qt_widget_private(popup)->stealKeyboardGrab(true); if (popupGrabOk) { - if (autoGrabber) - qt_widget_private(autoGrabber)->stealMouseGrab(false); - autoGrabber = 0; popupGrabOk = qt_widget_private(popup)->stealMouseGrab(true); if (!popupGrabOk) { // transfer grab back to the keyboard grabber if any diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index b731bec..589b360 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -1792,6 +1792,9 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie() QVERIFY(w); QTest::mouseMove(view.viewport()); QTest::mouseClick(view.viewport(), Qt::LeftButton, 0); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23699", Continue); +#endif QTRY_COMPARE(qApp->activeWindow(), static_cast(&view)); QTRY_COMPARE(scene.focusItem(), static_cast(w)); }