client: Always update the window's screen on changes

QWindow::screen can be set by an application programmatically or be
updated from the platform.

Currently when the QPA handles a screen change we compare against
mLastReportedScreen to determine if we need to update anything.

This results have a situation where sometimes we use the new value from
the platform, sometimes not, depending on which screens happened to be
used.

To be consistent, always check against the window's current screen.

Change-Id: I7ea15aa497a81d0cf46efe274f83f4667304623e
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
This commit is contained in:
David Edmundson 2024-05-09 11:03:57 +01:00
parent 2c9580bf63
commit 2f7a86fac3
2 changed files with 2 additions and 4 deletions

View File

@ -1437,14 +1437,13 @@ void QWaylandWindow::handleScreensChanged()
{
QPlatformScreen *newScreen = calculateScreenFromSurfaceEvents();
if (newScreen == mLastReportedScreen)
if (newScreen->screen() == window()->screen())
return;
if (!newScreen->isPlaceholder() && !newScreen->QPlatformScreen::screen())
mDisplay->forceRoundTrip();
QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
mLastReportedScreen = newScreen;
if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
&& window()->type() != Qt::ToolTip
&& geometry().topLeft() != newScreen->geometry().topLeft()) {
@ -1474,7 +1473,7 @@ void QWaylandWindow::updateScale()
return;
}
int scale = mLastReportedScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(mLastReportedScreen)->scale();
int scale = screen()->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(screen())->scale();
setScale(scale);
}

View File

@ -311,7 +311,6 @@ protected:
bool mSentInitialResize = false;
QPoint mOffset;
std::optional<qreal> mScale = 1;
QPlatformScreen *mLastReportedScreen = nullptr;
QString mWindowTitle;
QIcon mWindowIcon;