Fix QToolButton menus showing on primary screens in multiscreen setups

Calculate an initial position based on the current size hint
and pass it to QMenuPrivate::exec(), which does screen checks
based on it.

Amends a78d667431.

Pick-to: 5.15
Fixes: QTBUG-84462
Task-number: QTBUG-78966
Change-Id: Icae8d2bc0fb50c4c853cfebaa2b2250fc06542e3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Friedemann Kleint 2020-06-10 11:26:00 +02:00
parent fa5ae76356
commit ad532ce118

View File

@ -805,7 +805,8 @@ void QToolButtonPrivate::popupTimerDone()
// QTBUG-78966, Delay positioning until after aboutToShow().
auto positionFunction = [q, horizontal](const QSize &sizeHint) {
return positionMenu(q, horizontal, sizeHint); };
actualMenu->d_func()->exec({}, nullptr, positionFunction);
const auto initialPos = positionFunction(actualMenu->sizeHint());
actualMenu->d_func()->exec(initialPos, nullptr, positionFunction);
if (!that)
return;