Avoid rounding errors for fullscreen window geometry

Add a special case for handling Qt::WindowMaximized and
Qt::WindowFullScreen which don't call QPlatformWindow::
initialGeometry(). Handle the case by setting window
geometry to be equivalent to available screen geometry.

This avoids any rounding errors introduced by scaling
available screen geometry by a (possibly) fractional
scale factor.

Task-number: QTBUG-87334
Change-Id: Ia1b96057bdf3d3787f1b77b81078856fdd33fe9d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
bb10
Morten Sørvig 2023-11-02 13:20:42 +01:00
parent 96d0f2af75
commit 940e4e5428
1 changed files with 15 additions and 13 deletions

View File

@ -26,19 +26,21 @@ QAndroidPlatformWindow::QAndroidPlatformWindow(QWindow *window)
// the following is in relation to the virtual geometry
const bool forceMaximize = m_windowState & (Qt::WindowMaximized | Qt::WindowFullScreen);
const QRect requestedNativeGeometry =
forceMaximize ? QRect() : QHighDpi::toNativePixels(window->geometry(), window);
const QRect availableDeviceIndependentGeometry = (window->parent())
? window->parent()->geometry()
: QHighDpi::fromNativePixels(platformScreen()->availableGeometry(), window);
// initialGeometry returns in native pixels
const QRect finalNativeGeometry = QPlatformWindow::initialGeometry(
window, requestedNativeGeometry, availableDeviceIndependentGeometry.width(),
availableDeviceIndependentGeometry.height());
if (requestedNativeGeometry != finalNativeGeometry)
setGeometry(finalNativeGeometry);
const QRect nativeScreenGeometry = platformScreen()->availableGeometry();
if (forceMaximize) {
setGeometry(nativeScreenGeometry);
} else {
const QRect requestedNativeGeometry = QHighDpi::toNativePixels(window->geometry(), window);
const QRect availableDeviceIndependentGeometry = (window->parent())
? window->parent()->geometry()
: QHighDpi::fromNativePixels(nativeScreenGeometry, window);
// initialGeometry returns in native pixels
const QRect finalNativeGeometry = QPlatformWindow::initialGeometry(
window, requestedNativeGeometry, availableDeviceIndependentGeometry.width(),
availableDeviceIndependentGeometry.height());
if (requestedNativeGeometry != finalNativeGeometry)
setGeometry(finalNativeGeometry);
}
}
void QAndroidPlatformWindow::lower()