summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/multitouch/fingerpaint/scribblearea.cpp8
-rw-r--r--src/gui/kernel/qapplication_win.cpp7
-rw-r--r--src/gui/kernel/qevent.cpp14
-rw-r--r--src/gui/kernel/qevent.h3
-rw-r--r--src/gui/kernel/qevent_p.h1
5 files changed, 31 insertions, 2 deletions
diff --git a/examples/multitouch/fingerpaint/scribblearea.cpp b/examples/multitouch/fingerpaint/scribblearea.cpp
index a042fe7..ffff9bb 100644
--- a/examples/multitouch/fingerpaint/scribblearea.cpp
+++ b/examples/multitouch/fingerpaint/scribblearea.cpp
@@ -184,8 +184,12 @@ bool ScribbleArea::event(QEvent *event)
continue;
default:
{
- int diameter = int(50 * touchPoint->pressure());
- QRectF rectF(0, 0, diameter, diameter);
+ QSizeF area = touchPoint->area();
+ if (area.isEmpty()) {
+ qreal diameter = qreal(50) * touchPoint->pressure();
+ area = QSizeF(diameter, diameter);
+ }
+ QRectF rectF(QPointF(), area);
rectF.moveCenter(touchPoint->pos());
QRect rect = rectF.toRect();
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index b2411b0..d3bb6c2 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -4029,17 +4029,23 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
// update state
bool down = touchPoint->state() != Qt::TouchPointReleased;
QPointF screenPos(qreal(touchInput.x) / qreal(100.), qreal(touchInput.y) / qreal(100.));
+ QSizeF contactArea = (touchInput.dwMask & TOUCHINPUTMASKF_CONTACTAREA)
+ ? QSizeF(qreal(touchInput.cxContact) / qreal(100.),
+ qreal(touchInput.cyContact) / qreal(100.))
+ : QSizeF();
if (!down && (touchInput.dwFlags & TOUCHEVENTF_DOWN)) {
touchPoint->setState(Qt::TouchPointPressed);
touchPoint->setScreenPos(screenPos);
touchPoint->setStartScreenPos(screenPos);
touchPoint->setLastScreenPos(screenPos);
+ touchPoint->setArea(contactArea);
touchPoint->setPressure(qreal(1.));
} else if (down && (touchInput.dwFlags & TOUCHEVENTF_UP)) {
touchPoint->setState(Qt::TouchPointReleased);
touchPoint->setLastScreenPos(touchPoint->screenPos());
touchPoint->setScreenPos(screenPos);
+ touchPoint->setArea(QSizeF());
touchPoint->setPressure(qreal(0.));
} else if (down) {
touchPoint->setState(screenPos == touchPoint->screenPos()
@@ -4047,6 +4053,7 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
: Qt::TouchPointMoved);
touchPoint->setLastScreenPos(touchPoint->screenPos());
touchPoint->setScreenPos(screenPos);
+ touchPoint->setArea(contactArea);
// pressure should still be 1.
}
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 7a4c424..2692e82 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -3900,6 +3900,20 @@ void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
}
/*!
+ Returns the area of this touch point.
+*/
+QSizeF QTouchEvent::TouchPoint::area() const
+{
+ return d->area;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setArea(const QSizeF &area)
+{
+ d->area = area;
+}
+
+/*!
Returns the pressure of this touch point. The return value is in
the range 0.0 to 1.0.
*/
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 0c7d101..f622126 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -791,6 +791,9 @@ public:
QPointF lastScreenPos() const;
void setLastScreenPos(const QPointF &lastScreenPos);
+ QSizeF area() const;
+ void setArea(const QSizeF &area);
+
qreal pressure() const; // 0.0 -> 1.0
void setPressure(qreal pressure);
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index dd78c3e..37a0ee7 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -103,6 +103,7 @@ public:
QPointF pos, startPos, lastPos;
QPointF scenePos, startScenePos, lastScenePos;
QPointF screenPos, startScreenPos, lastScreenPos;
+ QSizeF area;
qreal pressure;
};