From 6811920dea2e864dc2b7231c18c8b72af5cab7f5 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 24 Jun 2013 16:09:49 +0200 Subject: [PATCH] Fix QWidget::isActiveWindow for window containers. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If0e8b83d7dc84b66f4ce5a5cd98affa4bd9b7424 Reviewed-by: Jørgen Lind --- src/widgets/kernel/qwidget.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index cfccce7c41..1c4ae9c8a2 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -104,6 +104,8 @@ #include "qtabwidget.h" // Needed in inTabWidget() #endif // QT_KEYPAD_NAVIGATION +#include "qwindowcontainer_p.h" + // widget/widget data creation count //#define QWIDGET_EXTRA_DEBUG @@ -6249,6 +6251,17 @@ bool QWidget::isActiveWindow() const } } + // Check for an active window container + if (QWindow *ww = QGuiApplication::focusWindow()) { + while (ww) { + QWidgetWindow *qww = qobject_cast(ww); + QWindowContainer *qwc = qww ? qobject_cast(qww->widget()) : 0; + if (qwc && qwc->topLevelWidget() == tlw) + return true; + ww = ww->parent(); + } + } + // Check if platform adaptation thinks the window is active. This is necessary for // example in case of ActiveQt servers that are embedded into another application. // Those are separate processes that are not part of the parent application Qt window/widget