diff options
author | Thorbjørn Lund Martsum <tmartsum@gmail.com> | 2018-12-04 13:31:39 +0100 |
---|---|---|
committer | Thorbjørn Lund Martsum <tmartsum@gmail.com> | 2018-12-18 11:22:37 +0000 |
commit | 7fc427ba23a624a433d93e1c604d870656835305 (patch) | |
tree | 2485195ccaa2962bc5291636faaab35a4482ae6f /src/widgets/widgets/qmenu.cpp | |
parent | 7863be311570fa219066df5fe8720d5b92ddb680 (diff) |
QToolTip - set correct screen before resize
In order to get a correctly not truncated size we need the hint to
be calculated based on the screen it is about to be shown on.
This patch places some code in QWidgetPrivate that is used by
QMenu and QToolTip + can be used to solve similar problems in the
future.
Task-number: QTBUG-72306
Change-Id: I58c058761f71b4a7675b6a078be62aa813ead752
Reviewed-by: Morten Kristensen <msk@nullpointer.dk>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmenu.cpp')
-rw-r--r-- | src/widgets/widgets/qmenu.cpp | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index c79e88f094..e3c29ff6ee 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -896,23 +896,6 @@ void QMenuPrivate::_q_overrideMenuActionDestroyed() menuAction=defaultMenuAction; } -void QMenuPrivate::adjustMenuScreen(const QPoint &p) -{ - Q_Q(QMenu); - // The windowHandle must point to the screen where the menu will be shown. - // The (item) size calculations depend on the menu screen, - // so a wrong screen would often cause wrong sizes (on high DPI) - const QScreen *currentScreen = q->windowHandle() ? q->windowHandle()->screen() : nullptr; - QScreen *actualScreen = QGuiApplication::screenAt(p); - if (actualScreen && currentScreen != actualScreen) { - if (!q->windowHandle()) // Try to create a window handle if not created. - createWinId(); - if (q->windowHandle()) - q->windowHandle()->setScreen(actualScreen); - itemsDirty = true; - } -} - void QMenuPrivate::updateLayoutDirection() { Q_Q(QMenu); @@ -2375,7 +2358,8 @@ void QMenu::popup(const QPoint &p, QAction *atAction) d->motions = 0; d->doChildEffects = true; d->updateLayoutDirection(); - d->adjustMenuScreen(p); + // Ensure that we get correct sizeHints by placing this window on the right screen. + d->setScreenForPoint(p); const bool contextMenu = d->isContextMenu(); if (d->lastContextMenu != contextMenu) { |