diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2009-06-23 13:45:33 (GMT) |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2009-06-23 13:45:33 (GMT) |
commit | 7971d94b84827b0d832ba72a80a19910add885d5 (patch) | |
tree | e04f83ccc41d41cfc0057537c663ba226e6ee8fa /src/gui/kernel/qmultitouch_mac.mm | |
parent | d8b81cad37e9477e609bbbedf0e666163bbbd813 (diff) | |
download | Qt-7971d94b84827b0d832ba72a80a19910add885d5.zip Qt-7971d94b84827b0d832ba72a80a19910add885d5.tar.gz Qt-7971d94b84827b0d832ba72a80a19910add885d5.tar.bz2 |
Multitouch, Cocoa: Implement normalized position
Diffstat (limited to 'src/gui/kernel/qmultitouch_mac.mm')
-rw-r--r-- | src/gui/kernel/qmultitouch_mac.mm | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gui/kernel/qmultitouch_mac.mm b/src/gui/kernel/qmultitouch_mac.mm index d3d423c..d9cb8b6 100644 --- a/src/gui/kernel/qmultitouch_mac.mm +++ b/src/gui/kernel/qmultitouch_mac.mm @@ -83,17 +83,18 @@ void QCocoaTouch::updateTouchData(NSTouch *nstouch, NSTouchPhase phase) // where on screen the touchpoint should be according to the // reference position: NSPoint npos = [nstouch normalizedPosition]; - _trackpadPos = QPointF(npos.x, npos.y); + QPointF qnpos = QPointF(npos.x, 1 - npos.y); + _touchPoint.setNormalizedPos(qnpos); if (_touchPoint.id() == 0 && phase == NSTouchPhaseBegan) { - _trackpadReferencePos = _trackpadPos; + _trackpadReferencePos = qnpos; _screenReferencePos = QCursor::pos(); } NSSize dsize = [nstouch deviceSize]; - float ppiX = (_trackpadPos.x() - _trackpadReferencePos.x()) * dsize.width; - float ppiY = (_trackpadPos.y() - _trackpadReferencePos.y()) * dsize.height; - QPointF relativePos = _trackpadReferencePos - QPointF(ppiX, 1 - ppiY); + float ppiX = (qnpos.x() - _trackpadReferencePos.x()) * dsize.width; + float ppiY = (qnpos.y() - _trackpadReferencePos.y()) * dsize.height; + QPointF relativePos = _trackpadReferencePos - QPointF(ppiX, ppiY); _touchPoint.setScreenPos(_screenReferencePos - relativePos); } |