summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-11-23 13:23:28 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-11-24 11:38:18 +0000
commit70d131af33c8b411f430d0699b4294b5976db8e3 (patch)
tree671a4e38b485a46164758897f169951ecb64f0ef /src
parent36f3eeaf3ec12126956d151a026379ab0385ab72 (diff)
Windows: Fix embedded application not getting focus after clicking outside
Amend the check introduced by bde6a049494f40cd71004d6926899f115af0c3e6 to not apply to embedded windows and plugin applications. Fixes: QTBUG-71991 Task-number: QTBUG-7081 Change-Id: I80b3dc0fa20ee3447a4bc4bbb41e66d4d90ab726 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qwidget.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index e59fbb8963..bcfae46155 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -6592,20 +6592,25 @@ QWidget *QWidgetPrivate::deepestFocusProxy() const
return focusProxy;
}
+static inline bool isEmbedded(const QWindow *w)
+{
+ const auto platformWindow = w->handle();
+ return platformWindow && platformWindow->isEmbedded();
+}
+
void QWidgetPrivate::setFocus_sys()
{
Q_Q(QWidget);
// Embedded native widget may have taken the focus; get it back to toplevel
// if that is the case (QTBUG-25852)
- const QWidget *topLevel = q->window();
- // Do not activate in case the popup menu opens another application (QTBUG-70810).
- if (QGuiApplication::applicationState() == Qt::ApplicationActive
- && topLevel->windowType() != Qt::Popup) {
- if (QWindow *nativeWindow = q->window()->windowHandle()) {
- if (nativeWindow != QGuiApplication::focusWindow()
- && q->testAttribute(Qt::WA_WState_Created)) {
- nativeWindow->requestActivate();
- }
+ // Do not activate in case the popup menu opens another application (QTBUG-70810)
+ // unless the application is embedded (QTBUG-71991).
+ if (QWindow *nativeWindow = q->testAttribute(Qt::WA_WState_Created) ? q->window()->windowHandle() : nullptr) {
+ if (nativeWindow->type() != Qt::Popup && nativeWindow != QGuiApplication::focusWindow()
+ && (QGuiApplication::applicationState() == Qt::ApplicationActive
+ || QCoreApplication::testAttribute(Qt::AA_PluginApplication)
+ || isEmbedded(nativeWindow))) {
+ nativeWindow->requestActivate();
}
}
}