From 793661ea091b535cd7dcf0651c1ca2425ea4b617 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Sun, 19 Jun 2022 12:54:12 +0100 Subject: [PATCH] Workaround QTBUG-102430, don't move still maximized window When dragging a maximized window we show normal, but we can only start moving it when the window managers acknowledges the new state. The state in QWidget isn't reliable. (cherry-picked from commit 6e7268e42af0589d7eb81aa9bbd0356ea75134fc) --- src/controllers/FloatingWindow.cpp | 2 +- src/private/DragController.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/controllers/FloatingWindow.cpp b/src/controllers/FloatingWindow.cpp index b889d7f1..b62f5ec3 100644 --- a/src/controllers/FloatingWindow.cpp +++ b/src/controllers/FloatingWindow.cpp @@ -126,7 +126,7 @@ FloatingWindow::FloatingWindow(QRect suggestedGeometry, MainWindow *parent) view()->setGeometry(suggestedGeometry); #ifdef Q_OS_WIN - // For QtQuick we do it a bit later, once we have the QQuickWindow + // For QtQuick we do it a bit later, once we have the QQuickWindow #ifdef KDDW_FRONTEND_QTWIDGETS if (Platform::instance()->isQtWidgets()) { view()->createPlatformWindow(); // QWidget::create diff --git a/src/private/DragController.cpp b/src/private/DragController.cpp index 322b0df7..ce218e98 100644 --- a/src/private/DragController.cpp +++ b/src/private/DragController.cpp @@ -416,6 +416,18 @@ bool StateDragging::handleMouseMove(QPoint globalPos) return true; } +#ifdef Q_OS_LINUX + if (fw->lastWindowManagerState() == Qt::WindowMaximized) { + // The window was maximized, we dragged it, which triggers a show normal. + // But we can only start moving the window *after* the (async) window manager acknowledges. + // See QTBUG-102430. + // Since #286 was only implemented and needed on Linux, then this counter-part is also ifdefed for Linux, + // Probably the ifdef could be removed, but don't want to be testing N platforms, who's undocumented behaviour + // can change between releases, so narrow the scope and workaround for linux only. + return true; + } +#endif + if (!q->m_nonClientDrag) fw->view()->window()->setFramePosition(globalPos - q->m_offset);