summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp8
-rw-r--r--tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp15
2 files changed, 18 insertions, 5 deletions
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index a2ca58e4c2..5bc3f11b3d 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -436,11 +436,9 @@ qreal QHighDpiScaling::roundScaleFactor(qreal rawFactor)
break;
}
- // Don't round down to to zero; clamp the minimum (rounded) factor to 1.
- // This is not a common case but can happen if a display reports a very
- // low DPI.
- if (scaleFactorRoundingPolicy != Qt::HighDpiScaleFactorRoundingPolicy::PassThrough)
- roundedFactor = qMax(roundedFactor, qreal(1));
+ // Clamp the minimum factor to 1. Qt does not currently render
+ // correctly with factors less than 1.
+ roundedFactor = qMax(roundedFactor, qreal(1));
return roundedFactor;
}
diff --git a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
index 09bf8439c8..512209ab73 100644
--- a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
+++ b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
@@ -49,6 +49,7 @@ private slots:
void initTestCase();
void qhighdpiscaling_data();
void qhighdpiscaling();
+ void minimumDpr();
void noscreens();
void screenDpiAndDpr_data();
void screenDpiAndDpr();
@@ -223,6 +224,20 @@ void tst_QHighDpi::screenDpiAndDpr()
}
}
+void tst_QHighDpi::minimumDpr()
+{
+ QList<qreal> dpiValues { 40, 60, 95 };
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+ for (QScreen *screen : app->screens()) {
+ // Qt does not currently support DPR values < 1. Make sure
+ // the minimum DPR value is 1, also when the screen reports
+ // a low DPI.
+ QCOMPARE(screen->devicePixelRatio(), 1);
+ QWindow window(screen);
+ QCOMPARE(window.devicePixelRatio(), 1);
+ }
+}
+
void tst_QHighDpi::noscreens()
{
// Create application object with a no-screens configuration (should not crash)