diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2016-11-21 12:51:02 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2016-11-23 22:40:58 +0000 |
commit | a1c84af6f57bc430c3f34bb79c035a27a9dd4348 (patch) | |
tree | 878e3d83f507f60bc17b9e7bef56d79d86be1922 /src/gui/kernel/qguiapplication.cpp | |
parent | 69d0eafa085324c0c8c0d198544b3df7e8f89d3e (diff) |
Refactor QGuiApplication::topLevelWindows()
Unifies the three conditions where we do not treat a window as a
top level window.
Uses QWindow::isTopLevel() instead of manually checking parent.
Updated the comment about embedded windows, which applies to all
embedded windows, not just QAxServers windows.
Change-Id: I7f9dbdf50044bf375ca21818ac29fbd3fe502166
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 14f94951d0..ccb392f968 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -937,15 +937,25 @@ QWindowList QGuiApplication::topLevelWindows() { const QWindowList &list = QGuiApplicationPrivate::window_list; QWindowList topLevelWindows; - for (int i = 0; i < list.size(); i++) { - if (!list.at(i)->parent() && list.at(i)->type() != Qt::Desktop) { - // Top windows of embedded QAxServers do not have QWindow parents, - // but they are not true top level windows, so do not include them. - const bool embedded = list.at(i)->handle() && list.at(i)->handle()->isEmbedded(); - if (!embedded) - topLevelWindows.prepend(list.at(i)); - } + for (int i = 0; i < list.size(); ++i) { + QWindow *window = list.at(i); + if (!window->isTopLevel()) + continue; + + // Desktop windows are special, as each individual desktop window + // will report that it's a top level window, but we don't want to + // include them in the application wide list of top level windows. + if (window->type() == Qt::Desktop) + continue; + + // Windows embedded in native windows do not have QWindow parents, + // but they are not true top level windows, so do not include them. + if (window->handle() && window->handle()->isEmbedded()) + continue; + + topLevelWindows.prepend(window); } + return topLevelWindows; } |