From 0a86c3127241aed93be62c62c3927e9383c95fd1 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Mon, 31 Mar 2014 15:25:44 +0300 Subject: 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 Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qapplication_qpa.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/widgets/kernel/qapplication_qpa.cpp') diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index 2f6e8acd87..5a4a4591bf 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -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) -- cgit v1.2.3