Save the last known window state from the window manager POV

Required for QTBUG-102430
This commit is contained in:
Sergio Martins
2022-04-12 14:56:20 +01:00
parent 9a9676cb7a
commit 7e6c5b2d9f
3 changed files with 14 additions and 1 deletions

View File

@@ -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())

View File

@@ -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<DropArea> m_dropArea;
TitleBar *const m_titleBar;
Qt::WindowState m_lastWindowManagerState = Qt::WindowNoState;
private:
Q_DISABLE_COPY(FloatingWindow)

View File

@@ -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;