Revert "Drop call to setPlatformScreen in QHighDpiScaling::setScreenFactor"
This reverts commit 7b2ae3faab15913e006ece25d785e6a8453dd27a. Reason for revert: this breaks multi-monitor XCB with HighDPI. Fixes: QTBUG-105079 Change-Id: I386c9480c33d1f67b3478332c8e03fe3eeeeee39 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Fushan Wen <qydwhotmail@gmail.com> (cherry picked from commit 392566cf61204dd28be0a6f2a252f9b5bd064e00) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9160cf6a07
commit
bf06976ef0
@ -555,8 +555,9 @@ 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()->updateLogicalDpi();
|
screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
|
||||||
}
|
}
|
||||||
|
|
||||||
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 QScreen;
|
friend class QScreenPrivate;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Qt doesn't currently support running with no platform screen
|
// Qt doesn't currently support running with no platform screen
|
||||||
|
@ -41,26 +41,7 @@ QScreen::QScreen(QPlatformScreen *screen)
|
|||||||
: QObject(*new QScreenPrivate(), nullptr)
|
: QObject(*new QScreenPrivate(), nullptr)
|
||||||
{
|
{
|
||||||
Q_D(QScreen);
|
Q_D(QScreen);
|
||||||
d->platformScreen = screen;
|
d->setPlatformScreen(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()
|
||||||
@ -90,6 +71,25 @@ 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…
x
Reference in New Issue
Block a user