Make touch operating better on some touchpads
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Sat, 2 Jun 2012 16:04:00 +0000 (19:04 +0300)
committerQt by Nokia <qt-info@nokia.com>
Tue, 5 Jun 2012 04:15:15 +0000 (06:15 +0200)
Some MT protocol capable touchpads do not provide
ABS_MT_TOUCH_MAJOR. The calculation for touch area was meaningless in
this case and resulted in a very small area not playing nice with apps
like fingerpaint.

Change-Id: Ibe472e22e5e792059fd594f54be9be8b75287730
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/platformsupport/input/evdevtouch/qevdevtouch.cpp

index 0f039a4..6bf9ba7 100644 (file)
@@ -82,7 +82,7 @@ public:
         Qt::TouchPointState state;
         QTouchEvent::TouchPoint::InfoFlags flags;
         Contact() : trackingId(-1),
-            x(0), y(0), maj(1), pressure(0),
+            x(0), y(0), maj(-1), pressure(0),
             state(Qt::TouchPointPressed), flags(0) { }
     };
     QHash<int, Contact> m_contacts; // The key is a tracking id for type A, slot number for type B.
@@ -479,7 +479,10 @@ void QEvdevTouchScreenData::reportPoints()
         const qreal wx = winRect.left() + tp.normalPosition.x() * winRect.width();
         const qreal wy = winRect.top() + tp.normalPosition.y() * winRect.height();
         const qreal sizeRatio = (winRect.width() + winRect.height()) / qreal(hw_w + hw_h);
-        tp.area = QRectF(0, 0, tp.area.width() * sizeRatio, tp.area.height() * sizeRatio);
+        if (tp.area.width() == -1) // touch major was not provided
+            tp.area = QRectF(0, 0, 8, 8);
+        else
+            tp.area = QRectF(0, 0, tp.area.width() * sizeRatio, tp.area.height() * sizeRatio);
         tp.area.moveCenter(QPointF(wx, wy));
 
         // Calculate normalized pressure.