QWaylandWindow: add QWaylandWindow::setScale
The logic for update window's scale is scattered in multiple places, we should unify their behavior. Change-Id: Ic8ba20fdbc44942aed9b4bd0b0b12dad7bee1719 Reviewed-by: Liang Qi <liang.qi@qt.io>
This commit is contained in:
parent
646bca0c74
commit
ad3bc01d35
@ -107,19 +107,8 @@ void QWaylandWindow::initWindow()
|
|||||||
|
|
||||||
connect(mFractionalScale.data(), &QWaylandFractionalScale::preferredScaleChanged, this, [this](qreal preferredScale) {
|
connect(mFractionalScale.data(), &QWaylandFractionalScale::preferredScaleChanged, this, [this](qreal preferredScale) {
|
||||||
preferredScale = std::max(1.0, preferredScale);
|
preferredScale = std::max(1.0, preferredScale);
|
||||||
if (mScale == preferredScale) {
|
Q_ASSERT(mViewport);
|
||||||
return;
|
setScale(preferredScale);
|
||||||
}
|
|
||||||
mScale = preferredScale;
|
|
||||||
QWindowSystemInterface::handleWindowDevicePixelRatioChanged(window());
|
|
||||||
ensureSize();
|
|
||||||
if (mViewport)
|
|
||||||
updateViewport();
|
|
||||||
if (isExposed()) {
|
|
||||||
// redraw at the new DPR
|
|
||||||
window()->requestUpdate();
|
|
||||||
sendExposeEvent(QRect(QPoint(), geometry().size()));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1394,17 +1383,28 @@ void QWaylandWindow::handleScreensChanged()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int scale = mLastReportedScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(mLastReportedScreen)->scale();
|
int scale = mLastReportedScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(mLastReportedScreen)->scale();
|
||||||
|
setScale(scale);
|
||||||
|
}
|
||||||
|
|
||||||
if (scale != mScale) {
|
void QWaylandWindow::setScale(qreal newScale)
|
||||||
mScale = scale;
|
{
|
||||||
QWindowSystemInterface::handleWindowDevicePixelRatioChanged(window());
|
if (qFuzzyCompare(mScale, newScale))
|
||||||
if (mSurface) {
|
return;
|
||||||
if (mViewport)
|
mScale = newScale;
|
||||||
updateViewport();
|
|
||||||
else if (mSurface->version() >= 3)
|
QWindowSystemInterface::handleWindowDevicePixelRatioChanged(window());
|
||||||
mSurface->set_buffer_scale(std::ceil(mScale));
|
if (mSurface) {
|
||||||
}
|
if (mViewport)
|
||||||
ensureSize();
|
updateViewport();
|
||||||
|
else if (mSurface->version() >= 3)
|
||||||
|
mSurface->set_buffer_scale(std::ceil(mScale));
|
||||||
|
}
|
||||||
|
ensureSize();
|
||||||
|
|
||||||
|
if (isExposed()) {
|
||||||
|
// redraw at the new DPR
|
||||||
|
window()->requestUpdate();
|
||||||
|
sendExposeEvent(QRect(QPoint(), geometry().size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,6 +346,7 @@ private:
|
|||||||
|
|
||||||
void handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e);
|
void handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e);
|
||||||
void handleScreensChanged();
|
void handleScreensChanged();
|
||||||
|
void setScale(qreal newScale);
|
||||||
void sendRecursiveExposeEvent();
|
void sendRecursiveExposeEvent();
|
||||||
|
|
||||||
QWaylandWindow *closestTransientParent() const;
|
QWaylandWindow *closestTransientParent() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user