From: GiWoong Kim Date: Sat, 9 May 2015 06:37:30 +0000 (+0900) Subject: touch: add out of bounds checking for multi-touch X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~454^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a1cea7d721fc1a4b6ce58e6bb117ab387e669f59;p=sdk%2Femulator%2Fqemu.git touch: add out of bounds checking for multi-touch Change-Id: I8cfcca3449cc8d12fb9dbc8b94632fe1b0666b32 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ui/displaybase.cpp b/tizen/src/ui/displaybase.cpp index 0a72b7f33b..0a2150498f 100644 --- a/tizen/src/ui/displaybase.cpp +++ b/tizen/src/ui/displaybase.cpp @@ -90,6 +90,16 @@ void DisplayBase::updateGeometry() rect.height() * scaleFactor); } +const QRect &DisplayBase::getGeometry() +{ + return widget->geometry(); +} + +QRegion DisplayBase::getMask() +{ + return widget->mask(); +} + void DisplayBase::handlePaint(QPaintEvent *event) { /* do nothing */ diff --git a/tizen/src/ui/displaybase.h b/tizen/src/ui/displaybase.h index 893707a46f..a43df941e7 100644 --- a/tizen/src/ui/displaybase.h +++ b/tizen/src/ui/displaybase.h @@ -47,6 +47,8 @@ public: void scaleForm(qreal scaleFactor); void update(); void updateGeometry(); + const QRect &getGeometry(); + QRegion getMask(); QPoint getGuestPos(QPoint hostPos); TouchScreenHelper *getTouchScreenHelper(); @@ -62,8 +64,6 @@ protected: void handleMouseRelease(QMouseEvent *event); void handleMouseMove(QMouseEvent *event); - QRect rect; - QPixmap maskImage; int rotateAngle; qreal scaleFactor; bool isDragging; @@ -71,6 +71,9 @@ protected: private: QWidget *widget; TouchScreenHelper *tsHelper; + + QRect rect; + QPixmap maskImage; }; #endif diff --git a/tizen/src/ui/input/multitouchtracker.cpp b/tizen/src/ui/input/multitouchtracker.cpp index 7bb6b49658..cb1e1e5374 100644 --- a/tizen/src/ui/input/multitouchtracker.cpp +++ b/tizen/src/ui/input/multitouchtracker.cpp @@ -244,17 +244,38 @@ void MultiTouchTracker::processingPara(QPoint hostPos, QPoint guestPos) const int hostPosDiffX = hostPos.x() - grabTouchPoint->getHostPos().x(); const int hostPosDiffY = hostPos.y() - grabTouchPoint->getHostPos().y(); - /* bounds checking */ - // TODO: + /* out of bounds checking */ + const QRect screenRect(QPoint(0, 0), + ((DisplayBase *)parent->getParent())->getGeometry().size()); + const QRegion screenRegion = + ((DisplayBase *)parent->getParent())->getMask(); + + for (int i = 0; i < touchPointList.count(); i++) { + point = touchPointList.at(i); + if (point != NULL) { + if (screenRegion.isNull() == false && + screenRegion.contains(QPoint( + point->getHostPos().x() + hostPosDiffX, + point->getHostPos().y() + hostPosDiffY)) == false) { + /* do nothing */ + return; + } else if (screenRect.contains( + point->getHostPos().x() + hostPosDiffX, + point->getHostPos().y() + hostPosDiffY, false) == false) { + /* do nothing */ + return; + } + } + } /* move whole touch points */ for (int i = 0; i < touchPointList.count(); i++) { point = touchPointList.at(i); if (point != NULL) { - QPoint hostMovedPos( + const QPoint hostMovedPos( point->getHostPos().x() + hostPosDiffX, point->getHostPos().y() + hostPosDiffY); - QPoint guestMovedPos = + const QPoint guestMovedPos = ((DisplayBase *)parent->getParent())->getGuestPos(hostMovedPos); point->updatePos(hostMovedPos, guestMovedPos); @@ -307,17 +328,38 @@ void MultiTouchTracker::processingSymm(QPoint hostPos, QPoint guestPos) virtio_touchscreen_event(guestPos.x(), guestPos.y(), grabTouchPoint->getID() - 1, 1); - /* bounds checking */ - // TODO: + /* out of bounds checking */ + const QRect screenRect(QPoint(0, 0), + ((DisplayBase *)parent->getParent())->getGeometry().size()); + const QRegion screenRegion = + ((DisplayBase *)parent->getParent())->getMask(); + + for (int i = 0; i < touchPointList.count(); i++) { + point = touchPointList.at(i); + if (point != NULL && point != grabTouchPoint) { + if (screenRegion.isNull() == false && + screenRegion.contains(QPoint( + point->getHostPos().x() - hostPosDiffX, + point->getHostPos().y() - hostPosDiffY)) == false) { + /* do nothing */ + return; + } else if (screenRect.contains( + point->getHostPos().x() - hostPosDiffX, + point->getHostPos().y() - hostPosDiffY, false) == false) { + /* do nothing */ + return; + } + } + } /* move other points */ for (int i = 0; i < touchPointList.count(); i++) { point = touchPointList.at(i); if (point != NULL && point != grabTouchPoint) { - QPoint hostMovedPos( + const QPoint hostMovedPos( point->getHostPos().x() - hostPosDiffX, point->getHostPos().y() - hostPosDiffY); - QPoint guestMovedPos = + const QPoint guestMovedPos = ((DisplayBase *)parent->getParent())->getGuestPos(hostMovedPos); point->updatePos(hostMovedPos, guestMovedPos);