summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-04-27 12:06:23 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-05-11 14:52:00 (GMT)
commitba7485012033b0447a9e77d5612db734f9dcffd6 (patch)
tree598a4877f357300a6516428c5ca613a2c3a28c3b
parentb3dbea5da34edb28a007ea7796de30204021a902 (diff)
downloadQt-ba7485012033b0447a9e77d5612db734f9dcffd6.zip
Qt-ba7485012033b0447a9e77d5612db734f9dcffd6.tar.gz
Qt-ba7485012033b0447a9e77d5612db734f9dcffd6.tar.bz2
Fixed gesture event propagation and offset translation.
-rw-r--r--src/gui/kernel/qapplication.cpp39
-rw-r--r--src/gui/kernel/qgesture.h1
-rw-r--r--src/gui/kernel/qgesturemanager.cpp23
3 files changed, 23 insertions, 40 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 39aeaa6..ebd62e6 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -4032,27 +4032,30 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
case QEvent::Gesture: {
QWidget *w = static_cast<QWidget*>(receiver);
- QGestureEvent *g = static_cast<QGestureEvent*>(e);
- bool eventAccepted = g->isAccepted();
- // Q_ASSERT(g->gesture() != 0);
- // const QGesture &gesture = *g->gesture();
- QPoint relPos(0,0);
+ QGestureEvent *ge = static_cast<QGestureEvent*>(e);
+ QSet<QString> eventGestures;
+ foreach(const QString &gesture, ge->gestureTypes())
+ eventGestures << gesture;
+ bool eventAccepted = ge->isAccepted();
+
+ QPoint offset;
while (w) {
- // QGesture qge(gesture.gestureType(), gesture.startPos()+relPos, gesture.lastPos()+relPos,
- // gesture.currentPos()+relPos, gesture.direction(), gesture.rect().translated(relPos),
- // gesture.hotSpot()+relPos, gesture.state(), gesture.startTime());
- // QGestureEvent ge(&qge, false);
- // ### TODO: fix widget-relative positions in gesture event.
- QGestureEvent ge = *g;
- ge.spont = g->spontaneous();
- res = d->notify_helper(w, w == receiver ? g : &ge);
- g->spont = false;
- eventAccepted = (w == receiver ? g : &ge)->isAccepted();
- if (res && eventAccepted)
- break;
+ QSet<int> widgetGestures = w->d_func()->gestures;
+ foreach(int gestureId, widgetGestures) {
+ if (eventGestures.contains(QGestureManager::instance()->gestureNameFromId(gestureId))) {
+ foreach(QGesture *gesture, ge->gestures())
+ gesture->translate(offset);
+ offset = QPoint();
+ res = d->notify_helper(w, ge);
+ ge->spont = false;
+ eventAccepted = ge->isAccepted();
+ if (res && eventAccepted)
+ break;
+ }
+ }
if (w->isWindow())
break;
- relPos += w->pos();
+ offset += w->pos();
w = w->parentWidget();
}
break;
diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h
index 2a92588..da1bc90 100644
--- a/src/gui/kernel/qgesture.h
+++ b/src/gui/kernel/qgesture.h
@@ -101,6 +101,7 @@ protected:
private:
friend class QGestureManager;
+ friend class QApplication;
friend class QGestureRecognizerPan;
friend class QDoubleTapGestureRecognizer;
friend class QTapAndHoldGestureRecognizer;
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp
index 994b2b6..b5b8fb8 100644
--- a/src/gui/kernel/qgesturemanager.cpp
+++ b/src/gui/kernel/qgesturemanager.cpp
@@ -482,28 +482,7 @@ void QGestureManager::recognizerStateChanged(QGestureRecognizer::Result result)
bool QGestureManager::sendGestureEvent(QWidget *receiver, QGestureEvent *event)
{
- QSet<QString> eventGestures;
- foreach(const QString &gesture, event->gestureTypes())
- eventGestures << gesture;
-
- QPoint offset;
- bool found = false;
- while (receiver) {
- QSet<int> widgetGestures = receiver->d_func()->gestures;
- foreach(int gestureId, widgetGestures) {
- if (eventGestures.contains(gestureNameFromId(gestureId))) {
- found = true;
- break;
- }
- }
- if (found)
- break;
- offset += receiver->pos();
- receiver = receiver->parentWidget();
- }
- foreach(QGesture *gesture, event->gestures())
- gesture->translate(offset);
- return receiver ? qt_sendSpontaneousEvent(receiver, event) : false;
+ return qt_sendSpontaneousEvent(receiver, event);
}
int QGestureManager::eventDeliveryDelay() const