From 635394c84a65d25cba2a9a283230d673bee4a8ae Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sun, 1 Nov 2015 18:56:52 +0100 Subject: [PATCH] WinRT: Fix wrong mouse event position for non-fullscreen windows When calling handleMouseEvent and similar, there are two choices when it comes to the global and local position: by specifying the window it is the caller's responsibility to provide a valid local position. When the window is null, QGuiApplication calculates the local position. The winrt plugin chose the former and therefore passing the global position as local is wrong. Task-number: QTBUG-48208 Change-Id: I3e1137cdb5d023296c4d73899da016641303c7df Reviewed-by: Andrew Knight --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 0fe3262398..d1a69c43f7 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -914,6 +914,11 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args) Point point; pointerPoint->get_Position(&point); QPointF pos(point.X * d->scaleFactor, point.Y * d->scaleFactor); + QPointF localPos = pos; + if (topWindow()) { + const QPointF globalPosDelta = pos - pos.toPoint(); + localPos = topWindow()->mapFromGlobal(pos.toPoint()) + globalPosDelta; + } VirtualKeyModifiers modifiers; args->get_KeyModifiers(&modifiers); @@ -947,7 +952,7 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args) boolean isHorizontal; properties->get_IsHorizontalMouseWheel(&isHorizontal); QPoint angleDelta(isHorizontal ? delta : 0, isHorizontal ? 0 : delta); - QWindowSystemInterface::handleWheelEvent(topWindow(), pos, pos, QPoint(), angleDelta, mods); + QWindowSystemInterface::handleWheelEvent(topWindow(), localPos, pos, QPoint(), angleDelta, mods); break; } @@ -973,7 +978,7 @@ HRESULT QWinRTScreen::onPointerUpdated(ICoreWindow *, IPointerEventArgs *args) if (isPressed) buttons |= Qt::XButton2; - QWindowSystemInterface::handleMouseEvent(topWindow(), pos, pos, buttons, mods); + QWindowSystemInterface::handleMouseEvent(topWindow(), localPos, pos, buttons, mods); break; }