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>
bb10
Morten Johan Sørvig 2019-12-19 13:51:56 +01:00
parent b31aef2900
commit 0f0d26418c
1 changed files with 8 additions and 0 deletions

View File

@ -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)
{