summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-11-01 18:56:52 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-11-02 09:16:31 +0000
commit635394c84a65d25cba2a9a283230d673bee4a8ae (patch)
treecd4642741f93d3ddcb5ab58053f42004bf8ea7ea /src/plugins/platforms
parent9b735a46182350e42495053ca741150a06f5c546 (diff)
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 <andrew.knight@intopalo.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/winrt/qwinrtscreen.cpp9
1 files 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;
}