From 3537f0e88571ab0bacda11bdf4bc34d007cabab7 Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Wed, 20 Jul 2022 09:55:07 +0200 Subject: [PATCH] Keep tolevel windows in the top left corner of the screen --- ...in-the-top-left-corner-of-the-screen.patch | 90 +++++++++++++++++++ qt5-qtwayland.spec | 10 ++- 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 0100-Keep-toplevel-windows-in-the-top-left-corner-of-the-screen.patch diff --git a/0100-Keep-toplevel-windows-in-the-top-left-corner-of-the-screen.patch b/0100-Keep-toplevel-windows-in-the-top-left-corner-of-the-screen.patch new file mode 100644 index 0000000..f2e6e43 --- /dev/null +++ b/0100-Keep-toplevel-windows-in-the-top-left-corner-of-the-screen.patch @@ -0,0 +1,90 @@ +From de46b3c6d1bef4b8f64c7db7069c8fd33ef23ed9 Mon Sep 17 00:00:00 2001 +From: David Redondo +Date: Wed, 8 Jun 2022 11:25:59 +0200 +Subject: [PATCH] Keep toplevel windows in the top left corner of the screen + +Cherry-picked from commit a46795a2. Fixes https://bugs.kde.org/show_bug.cgi?id=436016 +------------------------------------------------------------------------ +We can't know the actual position of a window on the screen. This causes +an issue when Widgets try to position a popup/menu absolutely and keep +it on the screen when the screen geometry doesn't include (0,0). +Instead report their positions always as the top left corner of +the screen that they are on. +This new behavior can be disabled for qt-shell or via an environment +variable by users that rely on the old behavior. + +Fixes: QTBUG-85297 +Change-Id: Iacb91cb03a0df87af950115760d2f41124ac06a3 +Reviewed-by: Qt CI Bot +Reviewed-by: David Edmundson +Reviewed-by: Aleix Pol Gonzalez +--- + src/client/qwaylandintegration.cpp | 4 ++++ + src/client/qwaylandwindow.cpp | 14 +++++++++++++- + src/client/qwaylandwindow_p.h | 3 +++ + 3 files changed, 20 insertions(+), 1 deletion(-) + +diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp +index fbf00c6b..5cd414e5 100644 +--- a/src/client/qwaylandintegration.cpp ++++ b/src/client/qwaylandintegration.cpp +@@ -117,6 +117,10 @@ QWaylandIntegration::QWaylandIntegration() + mFailed = true; + return; + } ++ ++ QWaylandWindow::fixedToplevelPositions = ++ !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS"); ++ + #if QT_CONFIG(clipboard) + mClipboard.reset(new QWaylandClipboard(mDisplay.data())); + #endif +diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp +index ceaa4c73..ec232cd2 100644 +--- a/src/client/qwaylandwindow.cpp ++++ b/src/client/qwaylandwindow.cpp +@@ -349,8 +349,13 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect) + } + } + +-void QWaylandWindow::setGeometry(const QRect &rect) ++void QWaylandWindow::setGeometry(const QRect &r) + { ++ auto rect = r; ++ if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup ++ && window()->type() != Qt::ToolTip) { ++ rect.moveTo(screen()->geometry().topLeft()); ++ } + setGeometry_helper(rect); + + if (window()->isVisible() && rect.isValid()) { +@@ -1023,6 +1028,13 @@ void QWaylandWindow::handleScreensChanged() + + 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()) { ++ auto geometry = this->geometry(); ++ geometry.moveTo(newScreen->geometry().topLeft()); ++ setGeometry(geometry); ++ } + + int scale = newScreen->isPlaceholder() ? 1 : static_cast(newScreen)->scale(); + if (scale != mScale) { +diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h +index cb9135f6..1907f10d 100644 +--- a/src/client/qwaylandwindow_p.h ++++ b/src/client/qwaylandwindow_p.h +@@ -98,6 +98,9 @@ public: + QWaylandWindow(QWindow *window, QWaylandDisplay *display); + ~QWaylandWindow() override; + ++ // Keep Toplevels position on the top left corner of their screen ++ static inline bool fixedToplevelPositions = true; ++ + virtual WindowType windowType() const = 0; + virtual void ensureSize(); + WId winId() const override; +-- +GitLab diff --git a/qt5-qtwayland.spec b/qt5-qtwayland.spec index 7e00d66..a50ee7c 100644 --- a/qt5-qtwayland.spec +++ b/qt5-qtwayland.spec @@ -3,7 +3,7 @@ Summary: Qt5 - Wayland platform support and QtCompositor module Name: qt5-%{qt_module} Version: 5.15.5 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPLv3 Url: http://www.qt.io @@ -56,6 +56,11 @@ Patch39: 0039-Fix-build-with-libcxx-missing-array-include.patch Patch50: 0050-Client-set-constraint-adjustments-for-popups-in-xdg.patch +# Menu location is offset depending on xdg_output.logical_layout in sway +# https://bugreports.qt.io/browse/QTBUG-85297 +# https://invent.kde.org/qt/qt/qtwayland/-/merge_requests/47 +Patch100: 0100-Keep-toplevel-windows-in-the-top-left-corner-of-the-screen.patch + # Disable for now, there is a Qt bug making this broken # Patch102: qtwayland-decoration-support-backports-from-qt6.patch Patch103: qtwayland-client-expose-toplevel-window-state.patch @@ -167,6 +172,9 @@ popd %changelog +* Wed Jul 20 2022 Jan Grulich - 5.15.5-2 +- Keep toplevel windows in the top left corner of the screen + * Wed Jul 13 2022 Jan Grulich - 5.15.5-1 - 5.15.5