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>bb10
parent
aa8fb36089
commit
dd52fd0024
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue