summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2011-09-20 15:45:29 +0200
committerQt by Nokia <qt-info@nokia.com>2011-09-20 17:38:04 +0200
commit6a56b95b3053b0834b053c1305b7716e02b5395d (patch)
tree786dcb36954f2fb3ea4a0a6ebe3c14309dd7dd79 /src/plugins
parent4d310b52ee1f81ac7bf67e33fd98d22a4fe18c43 (diff)
Cocoa: Adjust touch point rectangle by -0.5.
The actual touch point is supposed to be in the center of the rectangle, and since the rectangle is 1x1 it means we have to subtract 0.5 from x and y. Change-Id: Ica4aba26dbe61328c8e7cbdcf8b02c96e2f41a40 Reviewed-on: http://codereview.qt-project.org/5256 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Bjørn Erik Nilsen <bjorn.nilsen@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qmultitouch_mac.mm9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac.mm b/src/plugins/platforms/cocoa/qmultitouch_mac.mm
index 2f9aefca52..88c583cc7a 100644
--- a/src/plugins/platforms/cocoa/qmultitouch_mac.mm
+++ b/src/plugins/platforms/cocoa/qmultitouch_mac.mm
@@ -87,12 +87,19 @@ void QCocoaTouch::updateTouchData(NSTouch *nstouch, NSTouchPhase phase)
_screenReferencePos = qt_mac_flipPoint([NSEvent mouseLocation]);
}
+ QPointF screenPos = _screenReferencePos;
+
NSSize dsize = [nstouch deviceSize];
float ppiX = (qnpos.x() - _trackpadReferencePos.x()) * dsize.width;
float ppiY = (qnpos.y() - _trackpadReferencePos.y()) * dsize.height;
QPointF relativePos = _trackpadReferencePos - QPointF(ppiX, ppiY);
+ screenPos -= relativePos;
// Mac does not support area touch, only points, hence set width/height to 1.
- _touchPoint.area = QRectF(_screenReferencePos - relativePos, QSize(1, 1));
+ // The touch point is supposed to be in the center of '_touchPoint.area', and
+ // since width/height is 1 it means we must subtract 0.5 from x and y.
+ screenPos.rx() -= 0.5;
+ screenPos.ry() -= 0.5;
+ _touchPoint.area = QRectF(screenPos, QSize(1, 1));
}
QCocoaTouch *QCocoaTouch::findQCocoaTouch(NSTouch *nstouch)