Skip to content

Commit 201eed7

Browse files
committed
Merge pull request #94488 from Alex2782/fix_create_folder_94446
Fix `exclusive` child window
2 parents 8191042 + 4523514 commit 201eed7

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

scene/main/viewport.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,17 +272,31 @@ void Viewport::_sub_window_update_order() {
272272
return;
273273
}
274274

275-
if (!gui.sub_windows[gui.sub_windows.size() - 1].window->get_flag(Window::FLAG_ALWAYS_ON_TOP)) {
276-
int index = gui.sub_windows.size() - 1;
277-
278-
while (index > 0 && gui.sub_windows[index - 1].window->get_flag(Window::FLAG_ALWAYS_ON_TOP)) {
279-
--index;
275+
// Reorder 'always on top' windows.
276+
int last_index = gui.sub_windows.size() - 1;
277+
for (int index = last_index, insert_index = last_index; index >= 0; index--) {
278+
SubWindow sw = gui.sub_windows[index];
279+
Window *parent_window = sw.window->get_parent_visible_window();
280+
bool parent_is_always_on_top = (parent_window != nullptr) && parent_window->get_flag(Window::FLAG_ALWAYS_ON_TOP);
281+
if (sw.window->get_flag(Window::FLAG_ALWAYS_ON_TOP) || (parent_is_always_on_top && sw.window->is_exclusive())) {
282+
if (index != insert_index) {
283+
gui.sub_windows.remove_at(index);
284+
gui.sub_windows.insert(insert_index, sw);
285+
}
286+
insert_index--;
280287
}
288+
}
281289

282-
if (index != (gui.sub_windows.size() - 1)) {
283-
SubWindow sw = gui.sub_windows[gui.sub_windows.size() - 1];
284-
gui.sub_windows.remove_at(gui.sub_windows.size() - 1);
285-
gui.sub_windows.insert(index, sw);
290+
// Reorder exclusive children.
291+
for (int parent_index = 0; parent_index < gui.sub_windows.size(); parent_index++) {
292+
Window *exclusive_child = gui.sub_windows[parent_index].window->get_exclusive_child();
293+
if (exclusive_child != nullptr && exclusive_child->is_visible()) {
294+
int child_index = _sub_window_find(exclusive_child);
295+
if (child_index < parent_index) {
296+
SubWindow sw = gui.sub_windows[child_index];
297+
gui.sub_windows.remove_at(child_index);
298+
gui.sub_windows.insert(parent_index, sw);
299+
}
286300
}
287301
}
288302

0 commit comments

Comments
 (0)