hc
2023-02-13 e440ec23c5a540cdd3f7464e8779219be6fd3d95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From 8068f627c7bf883031203a5d663ee7badb816284 Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Wed, 4 Nov 2020 11:42:23 +0800
Subject: [PATCH 13/15] qwaylandwindow: Fix losing parent relationship after
 reset
 
Reset all children to reflush the parent relationship.
 
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 src/client/qwaylandwindow.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index 9b163ab..97282b8 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -245,6 +245,26 @@ void QWaylandWindow::initializeWlSurface()
         mSurface->m_window = this;
     }
     emit wlSurfaceCreated();
+
+    // Reset all children to reflush parent relationship
+    QObjectList childObjects = window()->children();
+    for (int i = 0; i < childObjects.size(); i ++) {
+        QObject *object = childObjects.at(i);
+
+        if (!object->isWindowType())
+            continue;
+
+        QWindow *childWindow = static_cast<QWindow *>(object);
+        if (!childWindow->isVisible())
+            return;
+
+        QWaylandWindow *childWaylandWindow =
+            const_cast<QWaylandWindow *>(static_cast<const QWaylandWindow *>(childWindow->handle()));
+
+        childWaylandWindow->reset();
+        childWaylandWindow->setParent(this);
+        childWindow->setVisible(true);
+    }
 }
 
 bool QWaylandWindow::shouldCreateShellSurface() const
-- 
2.20.1