diff --git a/src/private/FloatingWindow.cpp b/src/private/FloatingWindow.cpp index 226d9e86..a12b9e18 100644 --- a/src/private/FloatingWindow.cpp +++ b/src/private/FloatingWindow.cpp @@ -654,6 +654,11 @@ QRect FloatingWindow::normalGeometry() const return QWidgetAdapter::normalGeometry(); } +Qt::WindowState FloatingWindow::lastWindowManagerState() const +{ + return m_lastWindowManagerState; +} + int FloatingWindow::userType() const { if (Frame *f = singleFrame()) diff --git a/src/private/FloatingWindow_p.h b/src/private/FloatingWindow_p.h index 9a1319b4..660d3331 100644 --- a/src/private/FloatingWindow_p.h +++ b/src/private/FloatingWindow_p.h @@ -212,6 +212,11 @@ public: /// @sa QTBUG-95478 virtual QRect normalGeometry() const; + // The state reported by QWidget is not always the same as what the + // window manager thinks, due to the async nature. This method + // returns the last state reported by the window manager itself. + Qt::WindowState lastWindowManagerState() const; + ///@brief Allows the user app to specify which window flags to use, instead of KDDWs default ones ///Bugs caused by this won't be supported, as the amount of combinations that could go wrong can ///be open ended @@ -234,6 +239,7 @@ protected: QPointer m_dropArea; TitleBar *const m_titleBar; + Qt::WindowState m_lastWindowManagerState = Qt::WindowNoState; private: Q_DISABLE_COPY(FloatingWindow) diff --git a/src/private/widgets/FloatingWindowWidget.cpp b/src/private/widgets/FloatingWindowWidget.cpp index 81ec34be..235cf27e 100644 --- a/src/private/widgets/FloatingWindowWidget.cpp +++ b/src/private/widgets/FloatingWindowWidget.cpp @@ -96,8 +96,10 @@ bool FloatingWindowWidget::eventFilter(QObject *, QEvent *ev) // The sync one being useless, as the window manager can still have the old state. // Only emit windowStateChanged once the window manager tells us the state has actually changed // See also QTBUG-102430 - if (ev->spontaneous()) + if (ev->spontaneous()) { + m_lastWindowManagerState = windowHandle()->windowState(); Q_EMIT windowStateChanged(); + } } return false;