summaryrefslogtreecommitdiff
path: root/src/client/qwaylandwindow.cpp
diff options
context:
space:
mode:
authorDavid Redondo <qt@david-redondo.de>2022-06-08 11:25:59 +0200
committerDavid Redondo <qt@david-redondo.de>2022-06-22 09:12:24 +0200
commita46795a22e05722917c6ebc60ed01bebf49898ae (patch)
tree34cfe15ef4e4d63fc4e685e947c177f1b4b8e302 /src/client/qwaylandwindow.cpp
parentfeae5bef02a4c9ce280f55d231890243b1783946 (diff)
downloadqtwayland-a46795a22e05722917c6ebc60ed01bebf49898ae.tar.gz
Keep toplevel windows in the top left corner of the screen
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 <qt_ci_bot@qt-project.org> Reviewed-by: David Edmundson <davidedmundson@kde.org> Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
Diffstat (limited to 'src/client/qwaylandwindow.cpp')
-rw-r--r--src/client/qwaylandwindow.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index 888c4639..85266422 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -328,8 +328,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()) {
@@ -1210,6 +1215,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<QWaylandScreen *>(newScreen)->scale();
if (scale != mScale) {