summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2019-12-19 13:51:56 +0100
committerMorten Johan Sørvig <morten.sorvig@qt.io>2019-12-19 13:20:54 +0000
commit0f0d26418c185fe9e4c01049d165ac5548305354 (patch)
tree063a6406ec44dc77369e7c7b9212a26a9dd9c26a
parentb31aef2900478ef463c65dff5a3ea92b8fc047d7 (diff)
High-DPI: restore rounding behavior on Android
Qt 5.14 introduced QApplication::scaleFactorRoundingPolicy, where the default policy rounds the scale factor to an integer, which matches Qt's behavior on Windows and X11. However, Qt has never rounded scale factors on Android. Restore the historical behavior and document the platform difference. Change-Id: I0f8e8fb65e3874338ea290bbb12da350da22f099 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/gui/kernel/qguiapplication.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 7adba40fbd..6678b5f0ce 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -148,7 +148,13 @@ QString QGuiApplicationPrivate::styleOverride;
Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive;
Qt::HighDpiScaleFactorRoundingPolicy QGuiApplicationPrivate::highDpiScaleFactorRoundingPolicy =
+#ifdef Q_OS_ANDROID
+ // On Android, Qt has newer rounded the scale factor. Preserve
+ // that behavior by disabling rounding by default.
+ Qt::HighDpiScaleFactorRoundingPolicy::PassThrough;
+#else
Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor;
+#endif
bool QGuiApplicationPrivate::highDpiScalingUpdated = false;
QPointer<QWindow> QGuiApplicationPrivate::currentDragWindow;
@@ -3551,6 +3557,8 @@ Qt::ApplicationState QGuiApplication::applicationState()
accessor will reflect the environment, if set.
The default value is Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor.
+ On Qt for Android the default is Qt::HighDpiScaleFactorRoundingPolicy::PassThough,
+ which preserves historical behavior from earlier Qt versions.
*/
void QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy)
{