winrt: mouse handling: Fix detection of affected window

With the previous implementation the detection of the
affected window (windowAt which uses QWindow::geometry)
only worked for the upper left quarter of the window,
when used on a High DPI screen. As QWindow does not use
native positions, the mouse cursor's position has to be
mapped before checking the window under the mouse.

Change-Id: I1a30b9669ec3e4c573cf83aed57c20d65675ff16
Reviewed-by: Andre de la Rocha <andre.rocha@qt.io>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
This commit is contained in:
Oliver Wolff 2018-02-01 09:05:24 +01:00
parent 9d293e24a0
commit 675603a853

View File

@ -47,6 +47,7 @@
#endif
#include "qwinrtwindow.h"
#include <private/qeventdispatcher_winrt_p.h>
#include <private/qhighdpiscaling_p.h>
#include <QtCore/QLoggingCategory>
#include <QtGui/QSurfaceFormat>
@ -1126,11 +1127,11 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args)
// Common traits - point, modifiers, properties
Point point;
pointerPoint->get_Position(&point);
QPointF pos(point.X * d->scaleFactor, point.Y * d->scaleFactor);
const QPointF pos(point.X * d->scaleFactor, point.Y * d->scaleFactor);
QPointF localPos = pos;
const QPoint posPoint = pos.toPoint();
QWindow *windowUnderPointer = windowAt(posPoint);
QWindow *windowUnderPointer = windowAt(QHighDpiScaling::mapPositionFromNative(posPoint, this));
QWindow *targetWindow = windowUnderPointer;
if (d->mouseGrabWindow)