summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorMurray Read <ext-murray.2.read@nokia.com>2012-03-02 11:14:06 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-03-06 23:41:51 (GMT)
commit2fcee187856d066551ffb14657f10c9e961dff3f (patch)
treeaa8689147701e5e69d5bcd2579afa1751d9c3e0e /src/gui/kernel
parentc6bda755a2d0cad93520dbd75dc2880a1c9409e2 (diff)
downloadQt-2fcee187856d066551ffb14657f10c9e961dff3f.zip
Qt-2fcee187856d066551ffb14657f10c9e961dff3f.tar.gz
Qt-2fcee187856d066551ffb14657f10c9e961dff3f.tar.bz2
Correcting fixed native orientation translation for touch points
For a symbian application using fixed native orientation held in landscape, touches starting from the top of the screen were ignored. This was caused by an off-by-one error when reflecting touch positions. For example a touch in the range 0..359 could be mapped to the range 360..1. And since 0 mapped to a value outside of the valid range, touches starting with that were ignored. The same translation function is used for both touch points and rectangle coordinates, but these use different meanings for a point. For a touch, a point is the centre of the touched pixel, so translations should be against the last pixel, which is at size-1. But Symbian TRect points specify the edges of pixels, and these should be translated against the edge of the screen, which is at size. So the function now takes a parameter describing the type of translation required. Task-number: ou1cimx1#982747 Change-Id: I7af10b3a5b9b8658db9af8fa9bc04ad9cb531588 Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com> Reviewed-by: Gareth Stockwell <ext-gareth.stockwell@nokia.com>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qapplication_s60.cpp20
-rw-r--r--src/gui/kernel/qt_s60_p.h3
2 files changed, 13 insertions, 10 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 5e5df84..e24914f 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -625,23 +625,25 @@ void QSymbianControl::setWidget(QWidget *w)
qwidget = w;
}
-QPoint QSymbianControl::translatePointForFixedNativeOrientation(const TPoint &pointerEventPos) const
+QPoint QSymbianControl::translatePointForFixedNativeOrientation(const TPoint &pointerEventPos, TTranslationType translationType) const
{
QPoint pos(pointerEventPos.iX, pointerEventPos.iY);
if (qwidget->d_func()->fixNativeOrientationCalled) {
QSize wsize = qwidget->size(); // always same as the size in the native orientation
TSize size = Size(); // depends on the current orientation
+ // pixel center translations, eg touch points, should be reflected against the last pixel center, which is at size-1
+ int offset = (translationType == ETranslatePixelCenter) ? 1 : 0;
if (size.iWidth == wsize.height() && size.iHeight == wsize.width()) {
qreal x = pos.x();
qreal y = pos.y();
if (S60->screenRotation == QS60Data::ScreenRotation90) {
// DisplayRightUp
- pos.setX(size.iHeight - y);
+ pos.setX(size.iHeight - offset - y);
pos.setY(x);
} else if (S60->screenRotation == QS60Data::ScreenRotation270) {
// DisplayLeftUp
pos.setX(y);
- pos.setY(size.iWidth - x);
+ pos.setY(size.iWidth - offset - x);
}
}
}
@@ -652,8 +654,8 @@ TRect QSymbianControl::translateRectForFixedNativeOrientation(const TRect &contr
{
TRect rect = controlRect;
if (qwidget->d_func()->fixNativeOrientationCalled) {
- QPoint a = translatePointForFixedNativeOrientation(rect.iTl);
- QPoint b = translatePointForFixedNativeOrientation(rect.iBr);
+ QPoint a = translatePointForFixedNativeOrientation(rect.iTl, ETranslatePixelEdge);
+ QPoint b = translatePointForFixedNativeOrientation(rect.iBr, ETranslatePixelEdge);
if (a.x() < b.x()) {
rect.iTl.iX = a.x();
rect.iBr.iX = b.x();
@@ -675,8 +677,8 @@ TRect QSymbianControl::translateRectForFixedNativeOrientation(const TRect &contr
void QSymbianControl::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation )
{
QWidget *alienWidget;
- QPoint widgetPos = translatePointForFixedNativeOrientation(aPenEventLocation);
- QPoint globalPos = translatePointForFixedNativeOrientation(aPenEventScreenLocation);
+ QPoint widgetPos = translatePointForFixedNativeOrientation(aPenEventLocation, ETranslatePixelCenter);
+ QPoint globalPos = translatePointForFixedNativeOrientation(aPenEventScreenLocation, ETranslatePixelCenter);
alienWidget = qwidget->childAt(widgetPos);
if (!alienWidget)
alienWidget = qwidget;
@@ -713,7 +715,7 @@ void QSymbianControl::translateAdvancedPointerEvent(const TAdvancedPointerEvent
QSymbianControl::TouchEventParams QSymbianControl::TouchEventFromAdvancedPointerEvent(const TAdvancedPointerEvent *event)
{
QApplicationPrivate *d = QApplicationPrivate::instance();
- QPointF screenPos = qwidget->mapToGlobal(translatePointForFixedNativeOrientation(event->iPosition));
+ QPointF screenPos = qwidget->mapToGlobal(translatePointForFixedNativeOrientation(event->iPosition, ETranslatePixelCenter));
qreal pressure;
if (d->pressureSupported
&& event->Pressure() > 0) //workaround for misconfigured HAL
@@ -866,7 +868,7 @@ void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent)
Qt::KeyboardModifiers modifiers = mapToQtModifiers(pEvent.iModifiers);
app_keyboardModifiers = modifiers;
- QPoint widgetPos = translatePointForFixedNativeOrientation(pEvent.iPosition);
+ QPoint widgetPos = translatePointForFixedNativeOrientation(pEvent.iPosition, ETranslatePixelCenter);
TPoint controlScreenPos = PositionRelativeToScreen();
QPoint globalPos = QPoint(controlScreenPos.iX, controlScreenPos.iY) + widgetPos;
S60->lastCursorPos = globalPos;
diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h
index e1f50f4..2fc3227 100644
--- a/src/gui/kernel/qt_s60_p.h
+++ b/src/gui/kernel/qt_s60_p.h
@@ -275,7 +275,8 @@ public:
bool isControlActive();
void ensureFixNativeOrientation();
- QPoint translatePointForFixedNativeOrientation(const TPoint &pointerEventPos) const;
+ enum TTranslationType { ETranslatePixelCenter, ETranslatePixelEdge };
+ QPoint translatePointForFixedNativeOrientation(const TPoint &pointerEventPos, TTranslationType translationType) const;
TRect translateRectForFixedNativeOrientation(const TRect &controlRect) const;
#ifdef Q_WS_S60