diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-10-14 12:45:27 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-10-22 14:59:18 (GMT) |
commit | c5c1b878891b5ace5a71b95ea62229e26722fdba (patch) | |
tree | 7ef44d068a73c35efd938870c24fe6f0b778969e /src/gui | |
parent | d1a60dcbddbae46aaea655bb55c0c8fd46f38b2c (diff) | |
download | Qt-c5c1b878891b5ace5a71b95ea62229e26722fdba.zip Qt-c5c1b878891b5ace5a71b95ea62229e26722fdba.tar.gz Qt-c5c1b878891b5ace5a71b95ea62229e26722fdba.tar.bz2 |
Fixed gesture event delivery when several gestures are triggered.
When there are two different gestures are being triggered and they are
supposed to be sent to different widgets, don't stop event "propagation"
when the first event is successfully delivered.
Reviewed-by: trustme
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qapplication.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager.cpp | 41 |
2 files changed, 20 insertions, 23 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 30440eb..aee8afc 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -4183,7 +4183,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) res = d->notify_helper(w, &ge); gestureEvent->spont = false; eventAccepted = ge.isAccepted(); - if (res && eventAccepted) + if (res && eventAccepted && allGestures.isEmpty()) break; if (!eventAccepted) { // ### two ways to ignore the event/gesture diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 4f8a911..8928d1c 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -361,7 +361,8 @@ void QGestureManager::deliverEvents(const QSet<QGesture*> &gestures, GesturesPerReceiver groupedGestures; // for conflicted gestures the key is always the innermost widget (i.e. the child) GesturesPerReceiver conflictedGestures; - QMultiHash<QObject *, QGesture *> objectGestures; + typedef QMultiHash<QWidget *, QGesture *> WidgetMultiGestures; + WidgetMultiGestures widgetMultiGestures; foreach (QGesture *gesture, gestures) { QObject *target = gestureTargets.value(gesture, 0); @@ -380,7 +381,7 @@ void QGestureManager::deliverEvents(const QSet<QGesture*> &gestures, if (target) { gestureTargets.insert(gesture, target); if (target->isWidgetType()) - objectGestures.insert(target, gesture); + widgetMultiGestures.insert(static_cast<QWidget *>(target), gesture); groupedGestures[target].append(gesture); } else { qWarning() << "QGestureManager::deliverEvent: could not find the target for gesture" @@ -389,30 +390,26 @@ void QGestureManager::deliverEvents(const QSet<QGesture*> &gestures, } } - typedef QMultiHash<QObject *, QGesture *>::const_iterator ObjectGesturesIterator; - for (ObjectGesturesIterator it = objectGestures.begin(), - e = objectGestures.end(); it != e; ++it) { - QObject *object1 = it.key(); - QWidget *widget1 = qobject_cast<QWidget *>(object1); - QGraphicsObject *item1 = qobject_cast<QGraphicsObject *>(object1); + typedef WidgetMultiGestures::const_iterator WidgetMultiGesturesIterator; + for (WidgetMultiGesturesIterator it = widgetMultiGestures.begin(), + e = widgetMultiGestures.end(); it != e; ++it) { + QWidget *widget1 = it.key(); QGesture *gesture1 = it.value(); - ObjectGesturesIterator cit = it; + WidgetMultiGesturesIterator cit = it; for (++cit; cit != e; ++cit) { - QObject *object2 = cit.key(); - QWidget *widget2 = qobject_cast<QWidget *>(object2); - QGraphicsObject *item2 = qobject_cast<QGraphicsObject *>(object2); + QWidget *widget2 = cit.key(); QGesture *gesture2 = cit.value(); + if (gesture1->gestureType() != gesture2->gestureType()) + continue; // TODO: ugly, rewrite this. - if ((widget1 && widget2 && widget2->isAncestorOf(widget1)) || - (item1 && item2 && item2->isAncestorOf(item1))) { - groupedGestures[object2].removeOne(gesture2); - groupedGestures[object1].removeOne(gesture1); - conflictedGestures[object1].append(gesture1); - } else if ((widget1 && widget2 && widget1->isAncestorOf(widget2)) || - (item1 && item2 && item1->isAncestorOf(item2))) { - groupedGestures[object2].removeOne(gesture2); - groupedGestures[object1].removeOne(gesture1); - conflictedGestures[object2].append(gesture2); + if ((widget1 && widget2 && widget2->isAncestorOf(widget1))) { + groupedGestures[widget2].removeOne(gesture2); + groupedGestures[widget1].removeOne(gesture1); + conflictedGestures[widget1].append(gesture1); + } else if ((widget1 && widget2 && widget1->isAncestorOf(widget2))) { + groupedGestures[widget2].removeOne(gesture2); + groupedGestures[widget1].removeOne(gesture1); + conflictedGestures[widget2].append(gesture2); } } } |