summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qapplication.cpp
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-04-29 12:15:17 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-05-11 14:52:01 (GMT)
commita321909ced9fe28ea476ab95c7c7592db5090acc (patch)
treec3aa428dbc21785bb087a6cb8f3ac86bcbb7c637 /src/gui/kernel/qapplication.cpp
parentba7485012033b0447a9e77d5612db734f9dcffd6 (diff)
downloadQt-a321909ced9fe28ea476ab95c7c7592db5090acc.zip
Qt-a321909ced9fe28ea476ab95c7c7592db5090acc.tar.gz
Qt-a321909ced9fe28ea476ab95c7c7592db5090acc.tar.bz2
Generalized gesture filtering code to allow handling not only mouse
events in gesture recognizers.
Diffstat (limited to 'src/gui/kernel/qapplication.cpp')
-rw-r--r--src/gui/kernel/qapplication.cpp35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index ebd62e6..9772e0f 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -3588,6 +3588,18 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
#endif // !QT_NO_WHEELEVENT || !QT_NO_TABLETEVENT
}
+ if (!d->grabbedGestures.isEmpty() && e->spontaneous() && receiver->isWidgetType()) {
+ const QEvent::Type t = e->type();
+ if (t == QEvent::MouseButtonPress || t == QEvent::MouseButtonRelease || t == QEvent::MouseMove
+ || t == QEvent::MouseButtonDblClick || t == QEvent::Wheel
+ || t == QEvent::KeyPress || t == QEvent::KeyRelease
+ || t == QEvent::TabletPress || t == QEvent::TabletRelease || t == QEvent::TabletMove
+ || t >= QEvent::User) {
+ if (QGestureManager::instance()->filterEvent(static_cast<QWidget*>(receiver), e))
+ return true;
+ }
+ }
+
// User input and window activation makes tooltips sleep
switch (e->type()) {
case QEvent::Wheel:
@@ -3715,28 +3727,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
QPoint relpos = mouse->pos();
if (e->spontaneous()) {
- if (!d->grabbedGestures.isEmpty()) {
- QWidget *w = static_cast<QWidget*>(receiver);
- // if we are in gesture mode, we send all mouse events
- // directly to gesture recognizer.
- (void)QGestureManager::instance();
- if (d->gestureManager->inGestureMode()) {
- if (d->gestureManager->filterEvent(e))
- return true;
- } else {
- if (w && (mouse->type() != QEvent::MouseMove || mouse->buttons() != 0)) {
- // find the gesture target widget
- QWidget *target = w;
- while (target && target->d_func()->gestures.isEmpty())
- target = target->parentWidget();
- if (target) {
- d->gestureManager->setGestureTargetWidget(w);
- if (d->gestureManager->filterEvent(e))
- return true;
- }
- }
- }
- }
if (e->type() == QEvent::MouseButtonPress) {
QApplicationPrivate::giveFocusAccordingToFocusPolicy(w,
Qt::ClickFocus,
@@ -5107,7 +5097,6 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy)
*/
void QApplication::addGestureRecognizer(QGestureRecognizer *recognizer)
{
- Q_D(QApplication);
QGestureManager::instance()->addRecognizer(recognizer);
}