summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/qwaylandintegration.cpp3
-rw-r--r--src/client/qwaylandwindow.cpp14
-rw-r--r--src/client/qwaylandwindow_p.h3
-rw-r--r--src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.cpp1
4 files changed, 20 insertions, 1 deletions
diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp
index ed04e403..6d74de13 100644
--- a/src/client/qwaylandintegration.cpp
+++ b/src/client/qwaylandintegration.cpp
@@ -86,6 +86,9 @@ QWaylandIntegration::QWaylandIntegration()
return;
}
+ QWaylandWindow::fixedToplevelPositions =
+ !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+
// ### Not ideal...
// We don't want to use QPlatformWindow::requestActivate here, since that gives a warning
// for most shells. Also, we don't want to put this into the specific shells that can use
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index e8b50939..d669e839 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -331,8 +331,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()) {
@@ -1226,6 +1231,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) {
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
index e1280268..d2d4d659 100644
--- a/src/client/qwaylandwindow_p.h
+++ b/src/client/qwaylandwindow_p.h
@@ -76,6 +76,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;
diff --git a/src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.cpp b/src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.cpp
index 9b7b38b4..17b87033 100644
--- a/src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.cpp
+++ b/src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.cpp
@@ -22,6 +22,7 @@ namespace QtWaylandClient {
QWaylandQtShellIntegration::QWaylandQtShellIntegration()
: QWaylandShellIntegrationTemplate(1)
{
+ QWaylandWindow::fixedToplevelPositions = false;
}
QWaylandShellSurface *QWaylandQtShellIntegration::createShellSurface(QWaylandWindow *window)