aboutsummaryrefslogtreecommitdiffstats
path: root/community/qt5-qtbase/0001-Ensure-a-pixel-density-of-at-least-1-for-Qt-AA_Enabl.patch
blob: 6c3b3128a031bd4c974364445a0d482980f1abbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
From dd52fd0024600d3beffc82d6da02b4239a62d725 Mon Sep 17 00:00:00 2001
From: Jocelyn Turcotte <jturcotte@woboq.com>
Date: Tue, 17 Jan 2017 17:05:00 +0100
Subject: [PATCH] Ensure a pixel density of at least 1 for
 Qt::AA_EnableHighDpiScaling

Very large 1080p TVs or any display which is running at an abnormally
low resolution can have a DPI lower than 48, which means that
qRound(dpi/96) will result in a 0 pixel density, causing critical
issues for applications using Qt::AA_EnableHighDpiScaling.

Make sure that we always have a pixel density of at least 1 to allow
applications not having to worry about such displays.

Task-number: QTBUG-56140
Change-Id: I1dafbf7794a99ae6f872984c0337d8ff0d1fc1c0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
---
 src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp | 2 +-
 src/plugins/platforms/windows/qwindowsscreen.cpp            | 2 +-
 src/plugins/platforms/winrt/qwinrtscreen.cpp                | 2 +-
 src/plugins/platforms/xcb/qxcbscreen.cpp                    | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
index 3e1e93f1e4..863a115b74 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
@@ -226,7 +226,7 @@ QDpi QEglFSDeviceIntegration::logicalDpi() const
 
 qreal QEglFSDeviceIntegration::pixelDensity() const
 {
-    return qRound(logicalDpi().first / qreal(100));
+    return qMax(1, qRound(logicalDpi().first / qreal(100)));
 }
 
 Qt::ScreenOrientation QEglFSDeviceIntegration::nativeOrientation() const
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index 7a885b462e..c70323c06f 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -265,7 +265,7 @@ qreal QWindowsScreen::pixelDensity() const
     // the pixel density since it is reflects the Windows UI scaling.
     // High DPI auto scaling should be disabled when the user chooses
     // small fonts on a High DPI monitor, resulting in lower logical DPI.
-    return qRound(logicalDpi().first / 96);
+    return qMax(1, qRound(logicalDpi().first / 96));
 }
 
 /*!
diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp
index f87ae9fd24..2a4b6c8907 100644
--- a/src/plugins/platforms/winrt/qwinrtscreen.cpp
+++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp
@@ -647,7 +647,7 @@ QDpi QWinRTScreen::logicalDpi() const
 qreal QWinRTScreen::pixelDensity() const
 {
     Q_D(const QWinRTScreen);
-    return qRound(d->logicalDpi / 96);
+    return qMax(1, qRound(d->logicalDpi / 96));
 }
 
 qreal QWinRTScreen::scaleFactor() const
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index a9675935f4..d8facdbb84 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -631,7 +631,7 @@ void QXcbScreen::updateGeometry(const QRect &geom, uint8_t rotation)
         m_sizeMillimeters = sizeInMillimeters(xGeometry.size(), virtualDpi());
 
     qreal dpi = xGeometry.width() / physicalSize().width() * qreal(25.4);
-    m_pixelDensity = qRound(dpi/96);
+    m_pixelDensity = qMax(1, qRound(dpi/96));
     m_geometry = QRect(xGeometry.topLeft(), xGeometry.size());
     m_availableGeometry = xGeometry & m_virtualDesktop->workArea();
     QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry);
-- 
2.13.0