Windows: Account for not finding child windows when calling ChildWindowFromPointEx

The main code path of findPlatformWindowHelper had a check to verify
that the resulting child was not the parent HWND handle itself, but
the code path for handling QTBUG-40555 was missing this check, resulting
in infinite loops when the top level window was a transparent window.

We add the same kind of check to this code path, where neither the
hwnd out pointer or the result out pointer is updated. This is okey
since we return false and don't expect the function to continue
iterating based on an updated hwnd pointer.

Ideally the iteration logic should be moved into findPlatformWindowHelper
instead of having the outer loop outside of the function, but that's
left for another day.

Fixes: QTBUG-103571
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I9465253bca52bebf9137b24d7ce36646553d8d39
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Tor Arne Vestbø 2022-05-18 13:09:36 +02:00 committed by Volker Hilsheimer
parent 91710d8d76
commit cb51ab41e8

View File

@ -733,6 +733,8 @@ static inline bool findPlatformWindowHelper(const POINT &screenPoint, unsigned c
if (!(cwexFlags & CWP_SKIPTRANSPARENT)
&& (GetWindowLongPtr(child, GWL_EXSTYLE) & WS_EX_TRANSPARENT)) {
const HWND nonTransparentChild = ChildWindowFromPointEx(*hwnd, point, cwexFlags | CWP_SKIPTRANSPARENT);
if (!nonTransparentChild || nonTransparentChild == *hwnd)
return false;
if (QWindowsWindow *nonTransparentWindow = context->findPlatformWindow(nonTransparentChild)) {
*result = nonTransparentWindow;
*hwnd = nonTransparentChild;