Move QPlatformScreen::deviceIndependentGeometry() logic to QScreen
Having the logic in QPlatformScreen was inconsistent with how the high-DPI scaling logic sits on top of the platform layer, and also made the implementation of QScreenPrivate::updateHighDpi() a bit inconsistent in how the geometry vs available geometry was resolved. Change-Id: I683ab34dfc8579e2c887cb8fe3059c9c9fdb71a7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>bb10
parent
936d33849c
commit
a0b34a86b6
|
|
@ -435,13 +435,6 @@ QRect QPlatformScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation
|
|||
return rect;
|
||||
}
|
||||
|
||||
QRect QPlatformScreen::deviceIndependentGeometry() const
|
||||
{
|
||||
qreal scaleFactor = QHighDpiScaling::factor(this);
|
||||
QRect nativeGeometry = geometry();
|
||||
return QRect(nativeGeometry.topLeft(), QHighDpi::fromNative(nativeGeometry.size(), scaleFactor));
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a hint about this screen's subpixel layout structure.
|
||||
|
||||
|
|
|
|||
|
|
@ -124,9 +124,6 @@ public:
|
|||
static QTransform transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target);
|
||||
static QRect mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect);
|
||||
|
||||
// The platform screen's geometry in device independent coordinates
|
||||
QRect deviceIndependentGeometry() const;
|
||||
|
||||
static QDpi overrideDpi(const QDpi &in);
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -91,8 +91,10 @@ void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen)
|
|||
|
||||
void QScreenPrivate::updateHighDpi()
|
||||
{
|
||||
geometry = platformScreen->deviceIndependentGeometry();
|
||||
availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
|
||||
qreal scaleFactor = QHighDpiScaling::factor(platformScreen);
|
||||
QRect nativeGeometry = platformScreen->geometry();
|
||||
geometry = QRect(nativeGeometry.topLeft(), QHighDpi::fromNative(nativeGeometry.size(), scaleFactor));
|
||||
availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), scaleFactor, geometry.topLeft());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -97,9 +97,11 @@ QXcbScreen *QXcbWindow::parentScreen()
|
|||
return parent() ? static_cast<QXcbWindow*>(parent())->parentScreen() : xcbScreen();
|
||||
}
|
||||
|
||||
//QPlatformWindow::screenForGeometry version that uses deviceIndependentGeometry
|
||||
QXcbScreen *QXcbWindow::initialScreen() const
|
||||
{
|
||||
// Resolve initial screen via QWindowPrivate::screenForGeometry(),
|
||||
// which works in platform independent coordinates, as opposed to
|
||||
// QPlatformWindow::screenForGeometry() that uses native coordinates.
|
||||
QWindowPrivate *windowPrivate = qt_window_private(window());
|
||||
QScreen *screen = windowPrivate->screenForGeometry(window()->geometry());
|
||||
return static_cast<QXcbScreen*>(screen->handle());
|
||||
|
|
|
|||
Loading…
Reference in New Issue