summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2018-07-23 15:28:36 +0200
committerOliver Wolff <oliver.wolff@qt.io>2018-08-06 05:24:39 +0000
commitc1f86926a14f911ec7e578f63c96ba2292fa7cbe (patch)
tree0a808dbad12dfa7d7b748c7412ded9d2fb742cca /src
parentf51fc53844dcdf7a63b81b0abfd8ea553b9234ef (diff)
winrt: Fix QWinRTCursor::pos
On winrt top level windows are always considered fullscreen and the core window's bounds are considered the bounds of QScreen. Thus When checking the mouse cursor's position the window bounds have to be taken into consideration. Change-Id: I39f24399bbaeade58d547abc770d4b3094174160 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/winrt/qwinrtcursor.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/plugins/platforms/winrt/qwinrtcursor.cpp b/src/plugins/platforms/winrt/qwinrtcursor.cpp
index 6236ec1f2b..f22b9a435a 100644
--- a/src/plugins/platforms/winrt/qwinrtcursor.cpp
+++ b/src/plugins/platforms/winrt/qwinrtcursor.cpp
@@ -174,14 +174,23 @@ QPoint QWinRTCursor::pos() const
ICoreWindow *coreWindow = screen->coreWindow();
Q_ASSERT(coreWindow);
Point point;
- HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([coreWindow, &point]() {
- return coreWindow->get_PointerPosition(&point);
+ Rect bounds;
+ HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([coreWindow, &point, &bounds]() {
+ HRESULT hr = coreWindow->get_PointerPosition(&point);
+ RETURN_HR_IF_FAILED("Failed to obtain pointer position.");
+ hr = coreWindow->get_Bounds(&bounds);
+ RETURN_HR_IF_FAILED("Failed to obtain window bounds.");
+ return hr;
});
Q_ASSERT_SUCCEEDED(hr);
- const QPoint position = QPoint(point.X, point.Y) * screen->scaleFactor();
+ QPoint position = QPoint(point.X, point.Y);
// If no cursor get_PointerPosition returns SHRT_MIN for x and y
- return position.x() == SHRT_MIN && position.y() == SHRT_MIN || FAILED(hr) ? QPointF(Q_INFINITY, Q_INFINITY).toPoint()
- : position;
+ if (position.x() == SHRT_MIN && position.y() == SHRT_MIN || FAILED(hr))
+ return QPointF(Q_INFINITY, Q_INFINITY).toPoint();
+ position.rx() -= bounds.X;
+ position.ry() -= bounds.Y;
+ position *= screen->scaleFactor();
+ return position;
}
void QWinRTCursor::setPos(const QPoint &pos)