From 2f7a86fac338dc78259d93b675f1cd131c24c926 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 9 May 2024 11:03:57 +0100 Subject: [PATCH] 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 --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 5 ++--- src/plugins/platforms/wayland/qwaylandwindow_p.h | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 878332ca327..78244df3d92 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -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(mLastReportedScreen)->scale(); + int scale = screen()->isPlaceholder() ? 1 : static_cast(screen())->scale(); setScale(scale); } diff --git a/src/plugins/platforms/wayland/qwaylandwindow_p.h b/src/plugins/platforms/wayland/qwaylandwindow_p.h index 63b140f0b0f..3cd5db93544 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow_p.h +++ b/src/plugins/platforms/wayland/qwaylandwindow_p.h @@ -311,7 +311,6 @@ protected: bool mSentInitialResize = false; QPoint mOffset; std::optional mScale = 1; - QPlatformScreen *mLastReportedScreen = nullptr; QString mWindowTitle; QIcon mWindowIcon;