From c150c7a566234a7bf69fa114d493ac9839c57ad5 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Tue, 28 May 2019 18:24:33 +0200 Subject: [PATCH] Windows QPA: Optimize code that gets window under pointer It's not necessary to call QWindowsScreen::windowAt() for every mouse message received, but only when the mouse is captured, like it's done in the legacy mouse handler. Change-Id: Ib1035921291d22a32dfa3a619815a3f4ff9b3622 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowspointerhandler.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp index fd3d711470..8b88007949 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -269,7 +269,10 @@ static Qt::MouseButtons queryMouseButtons() static QWindow *getWindowUnderPointer(QWindow *window, QPoint globalPos) { - QWindow *currentWindowUnderPointer = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT); + QWindowsWindow *platformWindow = static_cast(window->handle()); + + QWindow *currentWindowUnderPointer = platformWindow->hasMouseCapture() ? + QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT) : window; while (currentWindowUnderPointer && currentWindowUnderPointer->flags() & Qt::WindowTransparentForInput) currentWindowUnderPointer = currentWindowUnderPointer->parent();