Windows QPA: Fix QGuiApplication::topLevelAt() with screen recorder applications

Special applications like screen recorders can create special, invisible
windows which are detected by the ChildWindowFromPointEx() as used in
QWindowsContext::findPlatformWindowAt(). Fall back to WindowFromPoint()
which skips those in case nothing is found.

Fixes: QTBUG-40815
Change-Id: Idb5253c412fb4522c844edf5eadedc6e0fad3979
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Friedemann Kleint 2019-05-28 14:22:07 +02:00
parent 978987981a
commit 0f417efe0f
1 changed files with 6 additions and 0 deletions

View File

@ -749,6 +749,12 @@ QWindowsWindow *QWindowsContext::findPlatformWindowAt(HWND parent,
QWindowsWindow *result = nullptr;
const POINT screenPoint = { screenPointIn.x(), screenPointIn.y() };
while (findPlatformWindowHelper(screenPoint, cwex_flags, this, &parent, &result)) {}
// QTBUG-40815: ChildWindowFromPointEx() can hit on special windows from
// screen recorder applications like ScreenToGif. Fall back to WindowFromPoint().
if (result == nullptr) {
if (const HWND window = WindowFromPoint(screenPoint))
result = findPlatformWindow(window);
}
return result;
}