From 8754c9fe83f8151adef46a05b5c6b6c47e9a56f3 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 19 Mar 2024 17:06:41 +0000 Subject: [PATCH] client: Workaround Gnome's incorrect xdg-geometry sizes Mutter, depending on the scaling mode, will sometimes send the xdg geometry size in device pixels rather than logical pixels. It is reported as https://gitlab.gnome.org/GNOME/mutter/-/issues/2631 but it is closed upstream so we cannot rely on them fixing it. This patch introduces the same workaround that GTK ships to work around this behavior. If the scale is set, and the xdg geometry matches the output geometry, then we can assume we don't have logical pixels for the xdg geometry and should calculate it manually. Fixes: QTBUG-122197 Change-Id: I7f640bac619be6eb07c84bb6913334a6356524a2 Pick-to: 6.8 6.7 6.5 Reviewed-by: Aleix Pol Gonzalez --- .../platforms/wayland/qwaylandscreen.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp index f0ac9fbace6..ef548925b62 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.cpp +++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp @@ -112,12 +112,19 @@ QString QWaylandScreen::model() const QRect QWaylandScreen::geometry() const { if (zxdg_output_v1::isInitialized()) { - return mXdgGeometry; - } else { - // Scale geometry for QScreen. This makes window and screen - // geometry be in the same coordinate system. - return QRect(mGeometry.topLeft(), mGeometry.size() / mScale); + + // Workaround for Gnome bug + // https://gitlab.gnome.org/GNOME/mutter/-/issues/2631 + // which sends an incorrect xdg geometry + const bool xdgGeometryIsBogus = mScale > 1 && mXdgGeometry.size() == mGeometry.size(); + + if (!xdgGeometryIsBogus) { + return mXdgGeometry; + } } + // Scale geometry for QScreen. This makes window and screen + // geometry be in the same coordinate system. + return QRect(mGeometry.topLeft(), mGeometry.size() / mScale); } int QWaylandScreen::depth() const