QMenu: Ensure popup() gets the right screen geometry
Many QMenu related functions end up calling sizeHint() which does call updateActionRects(). Since we try not to update the action rects if no action has changed, we must be careful to call it the first time with the right screen geometry. Other- wise, multi-display setups may get the action rects based on the wrong display. In QMenu::popup(), this can be solved by using the position passed as argument. Incidentally, we were already computing the right display geometry in the same function, only a bit later. The updated position around an eventual push button menu should not change the screen onto which the menu popup will be displayed. Tested with the multiscreen-menus manual test. Change-Id: Id7fc24be6908b4a9d24b8b9c8b8006efe45d69be Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
98c1d516b7
commit
35f927e719
@ -2323,7 +2323,17 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
|
||||
ensurePolished(); // Get the right font
|
||||
emit aboutToShow();
|
||||
const bool actionListChanged = d->itemsDirty;
|
||||
d->updateActionRects();
|
||||
|
||||
QRect screen;
|
||||
#ifndef QT_NO_GRAPHICSVIEW
|
||||
bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this);
|
||||
if (isEmbedded)
|
||||
screen = d->popupGeometry(this);
|
||||
else
|
||||
#endif
|
||||
screen = d->popupGeometry(QApplication::desktop()->screenNumber(p));
|
||||
d->updateActionRects(screen);
|
||||
|
||||
QPoint pos;
|
||||
QPushButton *causedButton = qobject_cast<QPushButton*>(d->causedPopup.widget);
|
||||
if (actionListChanged && causedButton)
|
||||
@ -2333,14 +2343,6 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
|
||||
|
||||
const QSize menuSizeHint(sizeHint());
|
||||
QSize size = menuSizeHint;
|
||||
QRect screen;
|
||||
#ifndef QT_NO_GRAPHICSVIEW
|
||||
bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this);
|
||||
if (isEmbedded)
|
||||
screen = d->popupGeometry(this);
|
||||
else
|
||||
#endif
|
||||
screen = d->popupGeometry(QApplication::desktop()->screenNumber(p));
|
||||
const int desktopFrame = style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, this);
|
||||
bool adjustToDesktop = !window()->testAttribute(Qt::WA_DontShowOnScreen);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user