summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2017-04-07 14:43:28 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2017-04-07 14:38:47 +0000
commit192aeed417a7fde91932ae3df8e2b1722e1bb449 (patch)
tree8aeed5b6052c82c05f62e41184b7d9d3abb68cf5 /src
parenta647004d9f349e0edc4254dcfe672ccf18f98ea7 (diff)
Fix menu position when highdpi scaling
Certain display and scale factor configurations would cause menus to pop up in incorrect locations or not be shown at all. This was due to QDesktopWidget::screenNumber() having a toNativePixels(QRect, QWindow) call which requires that QWindow::screen() returns the correct screen. Break the circular dependency by converting coordinates the other way for the intersection test: transform screen geometry to device independent coordinates. Task-number: QTBUG-58329 Change-Id: I5ff2a5b14296ddbf7d8ddca11420988aae6cc0bd (cherry picked from commit 5e76cb16924a42cb020786f45cc3494dd5836c5c) Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qdesktopwidget.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp
index 19e292375a..5877b4d49c 100644
--- a/src/widgets/kernel/qdesktopwidget.cpp
+++ b/src/widgets/kernel/qdesktopwidget.cpp
@@ -263,12 +263,13 @@ int QDesktopWidget::screenNumber(const QWidget *w) const
QRect frame = w->frameGeometry();
if (!w->isWindow())
frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0)));
- const QRect nativeFrame = QHighDpi::toNativePixels(frame, winHandle);
QScreen *widgetScreen = Q_NULLPTR;
int largestArea = 0;
foreach (QScreen *screen, screens) {
- const QRect intersected = screen->handle()->geometry().intersected(nativeFrame);
+ const QRect deviceIndependentScreenGeometry =
+ QHighDpi::fromNativePixels(screen->handle()->geometry(), screen);
+ const QRect intersected = deviceIndependentScreenGeometry.intersected(frame);
int area = intersected.width() * intersected.height();
if (largestArea < area) {
widgetScreen = screen;