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>
This commit is contained in:
Laszlo Agocs 2015-11-01 18:56:52 +01:00
parent 9b735a4618
commit 635394c84a

View File

@ -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;
}