summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmwindowstack.h
diff options
context:
space:
mode:
authorEven Oscar Andersen <even.oscar.andersen@qt.io>2025-05-23 12:37:25 +0200
committerEven Oscar Andersen <even.oscar.andersen@qt.io>2025-05-26 13:27:17 +0200
commite48c19449e3856661f4fe2ccd30d94ba9d61301f (patch)
tree91ca8efd1b4072dcdfc55c83eca67095a7b50de5 /src/plugins/platforms/wasm/qwasmwindowstack.h
parent3ad9d5777fe0771d14e89bb5601d602f2451bd49 (diff)
wasm: Fix stacking order problem for transient parent windows
Windows with a transient parent does not reflect the relationship in the stacking order. Essentially AboveTransientParent is missing as a configuration choice. What makes this slightly convoluted is that the window stack does not depend on the window (for testability). We solve this problem by making the stack and treenode templates, and provide test class as arguments when testing. QWasmWindow and QWasmScreen are not templated as before. There is also a new order type StayAboveTransientParent. Which means that we can no longer use order type to get to the group location (Since StayAboveTransientParent can map to either of the three types). The window stack tests have been updated to handle the StayAboveTransientParent type. Finally, we do not do anything with a normal parent child relationship as this should already work correctly. Fixes: QTBUG-131699 Change-Id: Ie08e18f9e0a2339175c4a09da0a831f031df71e1 Reviewed-by: Lorn Potter <lorn.potter@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmwindowstack.h')
-rw-r--r--src/plugins/platforms/wasm/qwasmwindowstack.h63
1 files changed, 45 insertions, 18 deletions
diff --git a/src/plugins/platforms/wasm/qwasmwindowstack.h b/src/plugins/platforms/wasm/qwasmwindowstack.h
index c75001157a0..90ad4c9dd15 100644
--- a/src/plugins/platforms/wasm/qwasmwindowstack.h
+++ b/src/plugins/platforms/wasm/qwasmwindowstack.h
@@ -6,6 +6,7 @@
#include <qglobal.h>
#include <QtCore/qlist.h>
+#include <QDebug>
#include <vector>
@@ -21,31 +22,49 @@ class QWasmWindow;
// Access to the top element is facilitated by |topWindow|.
// Changes to the top element are signaled via the |topWindowChangedCallback| supplied at
// construction.
+
+// Requirement Window
+//
+// type Window {
+// Window *transientParent() const;
+// Qt::WindowFlags windowFlags() const;
+// bool isModal() const;
+// };
+
+template <typename Window=QWasmWindow>
class Q_AUTOTEST_EXPORT QWasmWindowStack
{
-public:
- using WindowOrderChangedCallbackType = std::function<void()>;
-
- using StorageType = QList<QWasmWindow *>;
+private:
+ QWasmWindowStack(const QWasmWindowStack &) = delete;
+ QWasmWindowStack(QWasmWindowStack &&) = delete;
- using iterator = StorageType::reverse_iterator;
- using const_iterator = StorageType::const_reverse_iterator;
- using const_reverse_iterator = StorageType::const_iterator;
+ QWasmWindowStack &operator=(const QWasmWindowStack &) = delete;
+ QWasmWindowStack &&operator=(QWasmWindowStack &&) = delete;
+public:
enum class PositionPreference {
StayOnBottom,
Regular,
StayOnTop,
+ StayAboveTransientParent // Parent is transientParent()
};
+ using WindowOrderChangedCallbackType = std::function<void()>;
+ using StorageType = QList<Window *>;
+
+ using iterator = typename StorageType::reverse_iterator;
+ using const_iterator = typename StorageType::const_reverse_iterator;
+ using const_reverse_iterator = typename StorageType::const_iterator;
+
explicit QWasmWindowStack(WindowOrderChangedCallbackType topWindowChangedCallback);
~QWasmWindowStack();
- void pushWindow(QWasmWindow *window, PositionPreference position);
- void removeWindow(QWasmWindow *window);
- void raise(QWasmWindow *window);
- void lower(QWasmWindow *window);
- void windowPositionPreferenceChanged(QWasmWindow *window, PositionPreference position);
+ void pushWindow(Window *window, PositionPreference position, bool insertAtRegionBegin = false,
+ bool callCallbacks = true);
+ void removeWindow(Window *window, bool callCallbacks = true);
+ void raise(Window *window);
+ void lower(Window *window);
+ void windowPositionPreferenceChanged(Window *window, PositionPreference position);
// Iterates top-to-bottom
iterator begin();
@@ -59,17 +78,25 @@ public:
bool empty() const;
size_t size() const;
- QWasmWindow *topWindow() const;
+ Window *topWindow() const;
+ PositionPreference getWindowPositionPreference(typename StorageType::const_iterator windowIt,
+ bool testStayAbove = true) const;
private:
- PositionPreference getWindowPositionPreference(StorageType::iterator windowIt) const;
-
+ bool raiseImpl(Window *window);
+ bool lowerImpl(Window *window);
+ bool shouldBeAboveTransientParent(const Window *window) const;
+ bool shouldBeAboveTransientParentFlags(Qt::WindowFlags flags) const;
+ void invariant();
WindowOrderChangedCallbackType m_windowOrderChangedCallback;
- QList<QWasmWindow *> m_windowStack;
- StorageType::iterator m_regularWindowsBegin;
- StorageType::iterator m_alwaysOnTopWindowsBegin;
+
+ StorageType m_windowStack;
+ typename StorageType::iterator m_regularWindowsBegin;
+ typename StorageType::iterator m_alwaysOnTopWindowsBegin;
};
+#include "qwasmwindowstack.inc"
+
QT_END_NAMESPACE
#endif // QWASMWINDOWSTACK_H