diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-08-29 10:24:53 (GMT) |
---|---|---|
committer | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-08-29 11:56:39 (GMT) |
commit | 8f7535c3939e78f0c397d32945b577a98c234980 (patch) | |
tree | 646b8614fb90e3cb66f2b43633220a9bf2732c85 /src/gui | |
parent | 2485dea76dc36acb8fa9a5506ee66971ed89ff10 (diff) | |
download | Qt-8f7535c3939e78f0c397d32945b577a98c234980.zip Qt-8f7535c3939e78f0c397d32945b577a98c234980.tar.gz Qt-8f7535c3939e78f0c397d32945b577a98c234980.tar.bz2 |
Fix pointer event mapping when windows are fixed to native orientation
When the "fix native orientation" feature is enabled via
WA_SymbianNoSystemRotation, QSymbianControl has to do an extra
mapping for all pointer events because in this special mode the
RWindow and thus the CCoeControl will "rotate" (i.e. will change
their dimensions according to the orientation of the device),
however the EGL window surface and the QWidget will remain locked
to the native orientation of the device (typically portrait).
This means that the pointer events will correspond to the current
orientation of the device, which is not what Qt wants: typically
a graphics view or similar will perform the transformation of the
input events too, and therefore passing already-transformed events
is wrong (as it would result in double transformation). To solve
this, all pointer event coordinates are mapped back to the native
orientation.
This had a problem however: It only took the traditional portrait
and landscape modes into account. When there are two landscape modes
(i.e. rotations of both 90 and 270 degrees are supported), the
mapping of pointer events generated wrong results in one of them
because they treated them the same. The patch corrects this, so all
three orientations will result in proper input behavior, even when
NoSystemRotation is set.
Task-number: QT-5236
Reviewed-by: Sami Merila
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 15 | ||||
-rw-r--r-- | src/gui/kernel/qt_s60_p.h | 27 |
2 files changed, 38 insertions, 4 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 5ac9803..58fd0a8 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -580,13 +580,20 @@ QPoint QSymbianControl::translatePointForFixedNativeOrientation(const TPoint &po { QPoint pos(pointerEventPos.iX, pointerEventPos.iY); if (qwidget->d_func()->fixNativeOrientationCalled) { - QSize wsize = qwidget->size(); - TSize size = Size(); + QSize wsize = qwidget->size(); // always same as the size in the native orientation + TSize size = Size(); // depends on the current orientation if (size.iWidth == wsize.height() && size.iHeight == wsize.width()) { qreal x = pos.x(); qreal y = pos.y(); - pos.setX(size.iHeight - y); - pos.setY(x); + if (S60->screenRotation == QS60Data::ScreenRotation90) { + // DisplayRightUp + pos.setX(size.iHeight - y); + pos.setY(x); + } else if (S60->screenRotation == QS60Data::ScreenRotation270) { + // DisplayLeftUp + pos.setX(y); + pos.setY(size.iWidth - x); + } } } return pos; diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 3ec4052..96b8141 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -77,6 +77,7 @@ #include <akncontext.h> // CAknContextPane #include <eikspane.h> // CEikStatusPane #include <AknPopupFader.h> // MAknFadedComponent and TAknPopupFader +#include <bitstd.h> // EGraphicsOrientation constants #ifdef QT_SYMBIAN_HAVE_AKNTRANSEFFECT_H #include <gfxtranseffect/gfxtranseffect.h> // BeginFullScreen #include <akntranseffect.h> // BeginFullScreen @@ -213,6 +214,14 @@ public: int nativeScreenWidthInPixels; int nativeScreenHeightInPixels; + enum ScreenRotation { + ScreenRotation0, // portrait (or the native orientation) + ScreenRotation90, // typically DisplayLeftUp landscape + ScreenRotation180, // not used + ScreenRotation270 // DisplayRightUp landscape when 3-way orientation is supported + }; + ScreenRotation screenRotation; + int beginFullScreenCalled : 1; int endFullScreenCalled : 1; }; @@ -384,6 +393,24 @@ inline void QS60Data::updateScreenSize() inches = S60->screenWidthInTwips / (TReal)KTwipsPerInch; S60->defaultDpiX = S60->screenWidthInPixels / inches; + switch (params.iRotation) { + case CFbsBitGc::EGraphicsOrientationNormal: + S60->screenRotation = ScreenRotation0; + break; + case CFbsBitGc::EGraphicsOrientationRotated90: + S60->screenRotation = ScreenRotation90; + break; + case CFbsBitGc::EGraphicsOrientationRotated180: + S60->screenRotation = ScreenRotation180; + break; + case CFbsBitGc::EGraphicsOrientationRotated270: + S60->screenRotation = ScreenRotation270; + break; + default: + S60->screenRotation = ScreenRotation0; + break; + } + int screens = S60->screenCount(); for (int i = 0; i < screens; ++i) { CWsScreenDevice *dev = S60->screenDevice(i); |