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 <Friedemann.Kleint@qt.io>
This commit is contained in:
Andre de la Rocha 2019-05-28 18:24:33 +02:00
parent 0f417efe0f
commit c150c7a566

View File

@ -269,7 +269,10 @@ static Qt::MouseButtons queryMouseButtons()
static QWindow *getWindowUnderPointer(QWindow *window, QPoint globalPos) static QWindow *getWindowUnderPointer(QWindow *window, QPoint globalPos)
{ {
QWindow *currentWindowUnderPointer = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT); QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window->handle());
QWindow *currentWindowUnderPointer = platformWindow->hasMouseCapture() ?
QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT) : window;
while (currentWindowUnderPointer && currentWindowUnderPointer->flags() & Qt::WindowTransparentForInput) while (currentWindowUnderPointer && currentWindowUnderPointer->flags() & Qt::WindowTransparentForInput)
currentWindowUnderPointer = currentWindowUnderPointer->parent(); currentWindowUnderPointer = currentWindowUnderPointer->parent();