Drop call to setPlatformScreen in QHighDpiScaling::setScreenFactor
Drop call to setPlatformScreen since the only affected variables are logicalDpi and geometry. Replace setPlatformScreen with updateLogicalDpi which handles global scale factor changes in QScreen. Call updateGeometriesWithSignals() to check if there are any changes in geometry or availableGeometry, since the geometry or availableGeometry can also change when setting a scale factor. Move setPlatformScreen to QScreen ctor as the function is not used elsewhere. Pick-to: 6.4 6.3 6.2 Change-Id: I7acf40bf0643e89a1d9177674d66dc503829f98f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
9fcd5f0790
commit
7b2ae3faab
@ -555,9 +555,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
|
|||||||
else
|
else
|
||||||
QHighDpiScaling::m_namedScreenScaleFactors.insert(name, factor);
|
QHighDpiScaling::m_namedScreenScaleFactors.insert(name, factor);
|
||||||
|
|
||||||
// hack to force re-evaluation of screen geometry
|
|
||||||
if (screen->handle())
|
if (screen->handle())
|
||||||
screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
|
screen->d_func()->updateLogicalDpi();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
|
QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
|
||||||
|
@ -135,7 +135,7 @@ protected:
|
|||||||
QScopedPointer<QPlatformScreenPrivate> d_ptr;
|
QScopedPointer<QPlatformScreenPrivate> d_ptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class QScreenPrivate;
|
friend QScreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Qt doesn't currently support running with no platform screen
|
// Qt doesn't currently support running with no platform screen
|
||||||
|
@ -41,7 +41,26 @@ QScreen::QScreen(QPlatformScreen *screen)
|
|||||||
: QObject(*new QScreenPrivate(), nullptr)
|
: QObject(*new QScreenPrivate(), nullptr)
|
||||||
{
|
{
|
||||||
Q_D(QScreen);
|
Q_D(QScreen);
|
||||||
d->setPlatformScreen(screen);
|
d->platformScreen = screen;
|
||||||
|
d->platformScreen->d_func()->screen = this;
|
||||||
|
d->orientation = d->platformScreen->orientation();
|
||||||
|
|
||||||
|
d->logicalDpi = QPlatformScreen::overrideDpi(d->platformScreen->logicalDpi());
|
||||||
|
|
||||||
|
d->refreshRate = d->platformScreen->refreshRate();
|
||||||
|
// safeguard ourselves against buggy platform behavior...
|
||||||
|
if (d->refreshRate < 1.0)
|
||||||
|
d->refreshRate = 60.0;
|
||||||
|
|
||||||
|
d->updateHighDpi();
|
||||||
|
d->updatePrimaryOrientation(); // derived from the geometry
|
||||||
|
}
|
||||||
|
|
||||||
|
void QScreenPrivate::updateLogicalDpi()
|
||||||
|
{
|
||||||
|
Q_Q(QScreen);
|
||||||
|
logicalDpi = QPlatformScreen::overrideDpi(q->handle()->logicalDpi());
|
||||||
|
updateGeometriesWithSignals(); // updates geometries based on scale factor
|
||||||
}
|
}
|
||||||
|
|
||||||
void QScreenPrivate::updateGeometriesWithSignals()
|
void QScreenPrivate::updateGeometriesWithSignals()
|
||||||
@ -71,25 +90,6 @@ void QScreenPrivate::emitGeometryChangeSignals(bool geometryChanged, bool availa
|
|||||||
emit q->physicalDotsPerInchChanged(q->physicalDotsPerInch());
|
emit q->physicalDotsPerInchChanged(q->physicalDotsPerInch());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen)
|
|
||||||
{
|
|
||||||
Q_Q(QScreen);
|
|
||||||
platformScreen = screen;
|
|
||||||
platformScreen->d_func()->screen = q;
|
|
||||||
orientation = platformScreen->orientation();
|
|
||||||
|
|
||||||
logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
|
|
||||||
|
|
||||||
refreshRate = platformScreen->refreshRate();
|
|
||||||
// safeguard ourselves against buggy platform behavior...
|
|
||||||
if (refreshRate < 1.0)
|
|
||||||
refreshRate = 60.0;
|
|
||||||
|
|
||||||
updateHighDpi();
|
|
||||||
updatePrimaryOrientation(); // derived from the geometry
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Destroys the screen.
|
Destroys the screen.
|
||||||
*/
|
*/
|
||||||
|
@ -28,12 +28,12 @@ class QScreenPrivate : public QObjectPrivate
|
|||||||
{
|
{
|
||||||
Q_DECLARE_PUBLIC(QScreen)
|
Q_DECLARE_PUBLIC(QScreen)
|
||||||
public:
|
public:
|
||||||
void setPlatformScreen(QPlatformScreen *screen);
|
|
||||||
void updateHighDpi()
|
void updateHighDpi()
|
||||||
{
|
{
|
||||||
geometry = platformScreen->deviceIndependentGeometry();
|
geometry = platformScreen->deviceIndependentGeometry();
|
||||||
availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
|
availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
|
||||||
}
|
}
|
||||||
|
void updateLogicalDpi();
|
||||||
|
|
||||||
void updatePrimaryOrientation();
|
void updatePrimaryOrientation();
|
||||||
void updateGeometriesWithSignals();
|
void updateGeometriesWithSignals();
|
||||||
|
Loading…
Reference in New Issue
Block a user