When looking up the window hierarchy, stop at foreign windows

If the window being activated is an embedded window, the parent window
will be a foreign window (usually not even belonging to the current
process); we shouldn't attempt to focus it.

Task-number: QTBUG-37984
Change-Id: I2ea03a86b30bbc43cde643e18e0e1d020e5f2c84
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
Alberto Mardegan 2014-03-31 15:25:44 +03:00 committed by The Qt Project
parent b4128d0f7d
commit 0a86c31272

View File

@ -126,8 +126,15 @@ bool QApplicationPrivate::modalState()
QWidget *qt_tlw_for_window(QWindow *wnd)
{
while (wnd && !wnd->isTopLevel()) // QTBUG-32177, wnd might be a QQuickView embedded via window container.
wnd = wnd->parent();
// QTBUG-32177, wnd might be a QQuickView embedded via window container.
while (wnd && !wnd->isTopLevel()) {
QWindow *parent = wnd->parent();
// Don't end up in windows not belonging to this application
if (parent && parent->type() != Qt::ForeignWindow)
wnd = wnd->parent();
else
break;
}
if (wnd)
foreach (QWidget *tlw, qApp->topLevelWidgets())
if (tlw->windowHandle() == wnd)