Replace manual parent traversal in isWindowBlocked with use of isAncestorOf

Change-Id: I208d70a61e407069277339b3997c82921ab1b39b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
bb10
Tor Arne Vestbø 2016-11-22 15:36:29 +01:00
parent 1f81ba45ee
commit 5ea88ae239
2 changed files with 17 additions and 33 deletions

View File

@ -818,19 +818,11 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking
for (int i = 0; i < modalWindowList.count(); ++i) {
QWindow *modalWindow = modalWindowList.at(i);
{
// check if the modal window is our window or a (transient) parent of our window
QWindow *w = window;
while (w) {
if (w == modalWindow) {
*blockingWindow = 0;
return false;
}
QWindow *p = w->parent();
if (!p)
p = w->transientParent();
w = p;
}
// A window is not blocked by another modal window if the two are
// the same, or if the window is a child of the modal window.
if (window == modalWindow || modalWindow->isAncestorOf(window, QWindow::IncludeTransients)) {
*blockingWindow = 0;
return false;
}
Qt::WindowModality windowModality = modalWindow->modality();

View File

@ -2455,28 +2455,20 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin
for (int i = 0; i < modalWindowList.count(); ++i) {
QWindow *modalWindow = modalWindowList.at(i);
{
// check if the modal window is our window or a (transient) parent of our window
QWindow *w = window;
while (w) {
if (w == modalWindow) {
*blockingWindow = 0;
return false;
}
QWindow *p = w->parent();
if (!p)
p = w->transientParent();
w = p;
}
// Embedded in-process windows are not visible in normal parent-child chain,
// so check the native parent chain, too.
const QPlatformWindow *platWin = window->handle();
const QPlatformWindow *modalPlatWin = modalWindow->handle();
if (platWin && modalPlatWin && platWin->isEmbedded(modalPlatWin))
return false;
// A window is not blocked by another modal window if the two are
// the same, or if the window is a child of the modal window.
if (window == modalWindow || modalWindow->isAncestorOf(window, QWindow::IncludeTransients)) {
*blockingWindow = 0;
return false;
}
// Embedded windows are not visible in normal parent-child chain,
// so check the native parent chain, too.
const QPlatformWindow *platWin = window->handle();
const QPlatformWindow *modalPlatWin = modalWindow->handle();
if (platWin && modalPlatWin && platWin->isEmbedded(modalPlatWin))
return false;
Qt::WindowModality windowModality = modalWindow->modality();
QWidgetWindow *modalWidgetWindow = qobject_cast<QWidgetWindow *>(modalWindow);
if (windowModality == Qt::NonModal) {