summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwindow.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-04-20 14:04:18 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-04-21 10:32:47 +0000
commit414c751c7d8c81f7325a3ddee1d120a2056d05cf (patch)
treee5a2b923298582c546f820f2b590a9729c914a64 /src/gui/kernel/qwindow.cpp
parentb4c8455eeb57c750ab3fd45497575d3a954eb8b1 (diff)
Fall back to QWindow's screen when resolving DPR instead of using qApp
QGuiApplication::devicePixelRatio() should only be used when we don't know which window we're targeting. For QWindow::devicePixelRatio(), we can go though the associated screen to get a more accurate DPR. Change-Id: Idf511fa5c09562a6daf391cd4d0b8b99471045e7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/gui/kernel/qwindow.cpp')
-rw-r--r--src/gui/kernel/qwindow.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index c7afcce874..519d749b8a 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -1198,20 +1198,19 @@ Qt::ScreenOrientation QWindow::contentOrientation() const
Common values are 1.0 on normal displays and 2.0 on Apple "retina" displays.
\note For windows not backed by a platform window, meaning that create() was not
- called, the function will fall back to QGuiApplication::devicePixelRatio() which in
- turn returns the highest screen device pixel ratio found on the system.
+ called, the function will fall back to the associated QScreen's device pixel ratio.
- \sa QScreen::devicePixelRatio(), QGuiApplication::devicePixelRatio()
+ \sa QScreen::devicePixelRatio()
*/
qreal QWindow::devicePixelRatio() const
{
Q_D(const QWindow);
- // If there is no platform window use the app global devicePixelRatio,
- // which is the the highest devicePixelRatio found on the system
- // screens, and will be correct for single-display systems (a very common case).
+ // If there is no platform window use the associated screen's devicePixelRatio,
+ // which typically is the primary screen and will be correct for single-display
+ // systems (a very common case).
if (!d->platformWindow)
- return qApp->devicePixelRatio();
+ return screen()->devicePixelRatio();
return d->platformWindow->devicePixelRatio() * QHighDpiScaling::factor(this);
}