Call setFocus() if it is a QAxHostWidget which is in a new active window

The change 8c0f47cfae17a39137dec47aa0b9f3f9bedad introduced a problem
where if the widget was being reparented had a valid HWND then it would
cause the focus to change inside the already active window. Therefore we
need to limit the times it does this to the case where we know it needs to
be done which is the ActiveQt case.

Change-Id: Ia85f5136661142b25952e0ebf66f8a43d9500d58
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
This commit is contained in:
Andy Shaw 2015-11-06 11:03:15 +01:00
parent 2010eff9d7
commit b21c219811

View File

@ -2248,8 +2248,10 @@ void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous)
QApplication::setActiveWindow(tlw);
// QTBUG-37126, Active X controls may set the focus on native child widgets.
if (wnd && tlw && wnd != tlw->windowHandle()) {
if (QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(wnd))
widgetWindow->widget()->setFocus(Qt::ActiveWindowFocusReason);
if (QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(wnd)) {
if (widgetWindow->widget()->inherits("QAxHostWidget"))
widgetWindow->widget()->setFocus(Qt::ActiveWindowFocusReason);
}
}
}