Remove indirection via QScreenPrivate::setPlatformScreen()
The QHighDpiScaling code should call the explicit updateGeometry function instead to re-evaluate the platform screen geometry in light of the change to the scale factor. Change-Id: Idac975c117c431356f4fb812c245348c4722a8b5 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
c4debab927
commit
2187936978
@ -574,9 +574,7 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
|
||||
else
|
||||
QHighDpiScaling::m_namedScreenScaleFactors.insert(name, factor);
|
||||
|
||||
// hack to force re-evaluation of screen geometry
|
||||
if (screen->handle())
|
||||
screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
|
||||
screen->d_func()->updateGeometry();
|
||||
}
|
||||
|
||||
QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
|
||||
|
@ -132,7 +132,7 @@ protected:
|
||||
QScopedPointer<QPlatformScreenPrivate> d_ptr;
|
||||
|
||||
private:
|
||||
friend class QScreenPrivate;
|
||||
friend class QScreen;
|
||||
};
|
||||
|
||||
// Qt doesn't currently support running with no platform screen
|
||||
|
@ -37,29 +37,23 @@ QT_BEGIN_NAMESPACE
|
||||
\inmodule QtGui
|
||||
*/
|
||||
|
||||
QScreen::QScreen(QPlatformScreen *screen)
|
||||
QScreen::QScreen(QPlatformScreen *platformScreen)
|
||||
: QObject(*new QScreenPrivate(), nullptr)
|
||||
{
|
||||
Q_D(QScreen);
|
||||
d->setPlatformScreen(screen);
|
||||
}
|
||||
|
||||
void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen)
|
||||
{
|
||||
Q_Q(QScreen);
|
||||
platformScreen = screen;
|
||||
platformScreen->d_func()->screen = q;
|
||||
orientation = platformScreen->orientation();
|
||||
d->platformScreen = platformScreen;
|
||||
platformScreen->d_func()->screen = this;
|
||||
|
||||
logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
|
||||
|
||||
refreshRate = platformScreen->refreshRate();
|
||||
d->orientation = platformScreen->orientation();
|
||||
d->logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
|
||||
d->refreshRate = platformScreen->refreshRate();
|
||||
// safeguard ourselves against buggy platform behavior...
|
||||
if (refreshRate < 1.0)
|
||||
refreshRate = 60.0;
|
||||
if (d->refreshRate < 1.0)
|
||||
d->refreshRate = 60.0;
|
||||
|
||||
updateGeometry();
|
||||
updatePrimaryOrientation(); // derived from the geometry
|
||||
d->updateGeometry();
|
||||
d->updatePrimaryOrientation(); // derived from the geometry
|
||||
}
|
||||
|
||||
void QScreenPrivate::updateGeometry()
|
||||
|
@ -40,7 +40,6 @@ class QScreenPrivate : public QObjectPrivate, public QScreenData
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QScreen)
|
||||
public:
|
||||
void setPlatformScreen(QPlatformScreen *screen);
|
||||
void updateGeometry();
|
||||
void updatePrimaryOrientation();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user