summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorThorbjørn Lund Martsum <tmartsum@gmail.com>2017-11-21 08:46:57 +0100
committerThorbjørn Lund Martsum <tmartsum@gmail.com>2017-11-29 07:31:45 +0000
commitfb880bbdff7b4ff3ef1a3451d868ce595a14c29f (patch)
treed8ece6877e1dd1cc3065777e30f6754b16ee3487 /src/widgets
parent203fb838038d4c6c33d9e6ed3a45600c6e064e5a (diff)
QMenu: Corner case size fix (high DPI + multi screen)
We always need to set the QMenu screen explicit also when it is about to be shown on the primary screen. The reason is QWidget::metric (called from style/sizeHint) may use qApp->devicePixelRatioF() when it does not know about the topLevelWindow. That may not be the same value as DPR on primary screen. It can be argued that it likely is a bug in QWidget::metric, but fixing that looks to be a somewhat dangerous behavior change. Task-number: QTBUG-59794 Change-Id: I6ed0e808aa31bee5b77c0e19ce61a77548fdbb38 Reviewed-by: Morten Kristensen <msk@nullpointer.dk> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qmenu.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 196348f8e8..cf306e63bd 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -853,8 +853,7 @@ void QMenuPrivate::adjustMenuScreen(const QPoint &p)
// 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 *primaryScreen = QApplication::primaryScreen();
- const QScreen *currentScreen = q->windowHandle() ? q->windowHandle()->screen() : primaryScreen;
+ const QScreen *currentScreen = q->windowHandle() ? q->windowHandle()->screen() : nullptr;
const int screenNumberForPoint = QApplication::desktop()->screenNumber(p);
QScreen *actualScreen = QGuiApplication::screens().at(screenNumberForPoint);
if (actualScreen && currentScreen != actualScreen) {