Exclude invisible top level dialogs for whom a native
dialog is being shown from top-level search.
Change-Id: Ia94599905457d81d342c14d09ad0b0fc89ec4ab1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
if (const HWND hwnd = QApplicationPrivate::getHWNDForWidget(const_cast<QWidget *>(widget)))
return hwnd;
- const QWidgetList toplevels = QApplication::topLevelWidgets();
- if (!toplevels.isEmpty())
- if (const HWND topLevelHwnd = QApplicationPrivate::getHWNDForWidget(toplevels.front()))
- return topLevelHwnd;
+ // Find top level with native window (there might be dialogs that do not have one).
+ foreach (const QWidget *toplevel, QApplication::topLevelWidgets())
+ if (toplevel->windowHandle())
+ if (const HWND topLevelHwnd = QApplicationPrivate::getHWNDForWidget(toplevel))
+ return topLevelHwnd;
if (QDesktopWidget *desktop = qApp->desktop())
if (const HWND desktopHwnd = QApplicationPrivate::getHWNDForWidget(desktop))