Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwasmwindowtreenode.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5
6#include "qwasmwindow.h"
7
9 : m_childStack(std::bind(&QWasmWindowTreeNode::onTopWindowChanged, this))
10{
11}
12
14
16 QWasmWindowTreeNode *currentParent,
17 QWasmWindowStack::PositionPreference positionPreference)
18{
19 auto *window = asWasmWindow();
20 if (previousParent) {
21 previousParent->m_childStack.removeWindow(window);
23 window);
24 }
25
26 if (currentParent) {
27 currentParent->m_childStack.pushWindow(window, positionPreference);
29 window);
30 }
31}
32
34{
35 return nullptr;
36}
37
40{
41 if (changeType == QWasmWindowTreeNodeChangeType::NodeInsertion && parent == this
42 && m_childStack.topWindow()) {
43 m_childStack.topWindow()->requestActivateWindow();
44 }
45
46 if (parentNode())
47 parentNode()->onSubtreeChanged(changeType, parent, child);
48}
49
51{
52 window->setZOrder(z);
53}
54
56 QWasmWindowStack::PositionPreference positionPreference)
57{
58 if (parentNode()) {
60 positionPreference);
61 }
62}
63
65{
66 if (parentNode())
67 parentNode()->setActiveChildNode(asWasmWindow());
68}
69
71{
72 if (!parentNode())
73 return;
74 parentNode()->m_childStack.raise(asWasmWindow());
76}
77
79{
80 if (!parentNode())
81 return;
82 m_childStack.lower(asWasmWindow());
83}
84
85void QWasmWindowTreeNode::onTopWindowChanged()
86{
87 constexpr int zOrderForElementInFrontOfScreen = 3;
88 int z = zOrderForElementInFrontOfScreen;
89 std::for_each(m_childStack.rbegin(), m_childStack.rend(),
90 [this, &z](QWasmWindow *window) { setWindowZOrder(window, z++); });
91}
92
93void QWasmWindowTreeNode::setActiveChildNode(QWasmWindow *activeChild)
94{
95 m_activeChild = activeChild;
96
97 auto it = m_childStack.begin();
98 if (it == m_childStack.end())
99 return;
100 for (; it != m_childStack.end(); ++it)
101 (*it)->onActivationChanged(*it == m_activeChild);
102
104}
void lower(QWasmWindow *window)
QWasmWindow * topWindow() const
const_reverse_iterator rbegin() const
void removeWindow(QWasmWindow *window)
const_reverse_iterator rend() const
void raise(QWasmWindow *window)
void pushWindow(QWasmWindow *window, PositionPreference position)
void windowPositionPreferenceChanged(QWasmWindow *window, PositionPreference position)
QWasmWindow * activeChild() const
virtual ~QWasmWindowTreeNode()
virtual void onParentChanged(QWasmWindowTreeNode *previous, QWasmWindowTreeNode *current, QWasmWindowStack::PositionPreference positionPreference)
virtual QWasmWindowTreeNode * parentNode()=0
virtual void onSubtreeChanged(QWasmWindowTreeNodeChangeType changeType, QWasmWindowTreeNode *parent, QWasmWindow *child)
virtual QWasmWindow * asWasmWindow()
virtual void setWindowZOrder(QWasmWindow *window, int z)
void onPositionPreferenceChanged(QWasmWindowStack::PositionPreference positionPreference)
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
#define this
Definition dialogs.cpp:9
QSet< QString >::iterator it
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
QWasmWindowTreeNodeChangeType
QLayoutItem * child
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
socketLayer bind(QHostAddress::Any, 4000)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent