Open menu on the third click on QMenuBar on X11

We don't replay mouse events after closing popups on X11.
This leads to the bug when the menu doesn't show after
clicking three times on the menu bar. It can be fixed by
reverting 78d7192338, but
then we need an alternative fix for QTBUG-32807 on Windows.
So don't replay mouse events for the menu bar on all
platforms.

Change-Id: I3db8e24a6de6f35b0a17dffac6a131f1cad42e6d
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
This commit is contained in:
Alexander Volkov 2015-06-10 13:33:09 +03:00
parent 734557bb84
commit 0636ec4ff5
2 changed files with 8 additions and 5 deletions

View File

@ -1042,8 +1042,8 @@ void QMenuBar::mousePressEvent(QMouseEvent *e)
if(d->currentAction == action && d->popupState) {
if(QMenu *menu = d->activeMenu) {
d->activeMenu = 0;
menu->setAttribute(Qt::WA_NoMouseReplay);
menu->hide();
d->closePopupMode = 1;
}
} else {
d->setCurrentAction(action, true);

View File

@ -128,7 +128,7 @@ private slots:
void taskQTBUG4965_escapeEaten();
#endif
void taskQTBUG11823_crashwithInvisibleActions();
void closeOnSecondClick();
void closeOnSecondClickAndOpenOnThirdClick();
void cornerWidgets_data();
void cornerWidgets();
@ -1312,7 +1312,7 @@ void tst_QMenuBar::taskQTBUG11823_crashwithInvisibleActions()
QCOMPARE(menubar.activeAction(), m); //the active action shouldn't have changed
}
void tst_QMenuBar::closeOnSecondClick() // QTBUG-32807, menu should close on 2nd click.
void tst_QMenuBar::closeOnSecondClickAndOpenOnThirdClick() // QTBUG-32807, menu should close on 2nd click.
{
QMainWindow mainWindow;
mainWindow.resize(300, 200);
@ -1322,17 +1322,20 @@ void tst_QMenuBar::closeOnSecondClick() // QTBUG-32807, menu should close on 2nd
#endif
QMenuBar *menuBar = mainWindow.menuBar();
menuBar->setNativeMenuBar(false);
QMenu *fileMenu = menuBar->addMenu(QStringLiteral("closeOnSecondClick"));
QMenu *fileMenu = menuBar->addMenu(QStringLiteral("OpenCloseOpen"));
fileMenu->addAction(QStringLiteral("Quit"));
mainWindow.show();
QApplication::setActiveWindow(&mainWindow);
QVERIFY(QTest::qWaitForWindowActive(&mainWindow));
const QPoint center = menuBar->actionGeometry(fileMenu->menuAction()).center();
const QPoint globalPos = menuBar->mapToGlobal(center);
QTest::mouseMove(menuBar, center);
QTest::mouseClick(menuBar, Qt::LeftButton, 0, center);
QTRY_VERIFY(fileMenu->isVisible());
QTest::mouseClick(menuBar, Qt::LeftButton, 0, center);
QTest::mouseClick(fileMenu, Qt::LeftButton, 0, fileMenu->mapFromGlobal(globalPos));
QTRY_VERIFY(!fileMenu->isVisible());
QTest::mouseClick(menuBar, Qt::LeftButton, 0, center);
QTRY_VERIFY(fileMenu->isVisible());
}
Q_DECLARE_METATYPE(Qt::Corner)