src/gui/kernel/qapplication.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
child 7 f7bc934e204c
child 18 2f34d5167611
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   152 bool QApplicationPrivate::autoSipEnabled = false;
   152 bool QApplicationPrivate::autoSipEnabled = false;
   153 #else
   153 #else
   154 bool QApplicationPrivate::autoSipEnabled = true;
   154 bool QApplicationPrivate::autoSipEnabled = true;
   155 #endif
   155 #endif
   156 
   156 
   157 QGestureManager* QGestureManager::instance()
       
   158 {
       
   159     QApplicationPrivate *d = qApp->d_func();
       
   160     if (!d->gestureManager)
       
   161         d->gestureManager = new QGestureManager(qApp);
       
   162     return d->gestureManager;
       
   163 }
       
   164 
       
   165 QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type)
   157 QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type)
   166     : QCoreApplicationPrivate(argc, argv)
   158     : QCoreApplicationPrivate(argc, argv)
   167 {
   159 {
   168     application_type = type;
   160     application_type = type;
   169     qt_appType = type;
   161     qt_appType = type;
   183 #endif
   175 #endif
   184 #if defined(Q_WS_QWS) && !defined(QT_NO_DIRECTPAINTER)
   176 #if defined(Q_WS_QWS) && !defined(QT_NO_DIRECTPAINTER)
   185     directPainters = 0;
   177     directPainters = 0;
   186 #endif
   178 #endif
   187 
   179 
   188     gestureManager = 0;
   180     gestureWidget = 0;
   189 
   181 
   190     if (!self)
   182     if (!self)
   191         self = this;
   183         self = this;
   192 }
   184 }
   193 
   185 
   472 bool QApplicationPrivate::animate_tooltip = false;
   464 bool QApplicationPrivate::animate_tooltip = false;
   473 bool QApplicationPrivate::fade_tooltip = false;
   465 bool QApplicationPrivate::fade_tooltip = false;
   474 bool QApplicationPrivate::animate_toolbox = false;
   466 bool QApplicationPrivate::animate_toolbox = false;
   475 bool QApplicationPrivate::widgetCount = false;
   467 bool QApplicationPrivate::widgetCount = false;
   476 bool QApplicationPrivate::load_testability = false;
   468 bool QApplicationPrivate::load_testability = false;
   477 #if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
       
   478 bool QApplicationPrivate::inSizeMove = false;
       
   479 #endif
       
   480 #ifdef QT_KEYPAD_NAVIGATION
   469 #ifdef QT_KEYPAD_NAVIGATION
   481 #  ifdef Q_OS_SYMBIAN
   470 #  ifdef Q_OS_SYMBIAN
   482 Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional;
   471 Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional;
   483 #  else
   472 #  else
   484 Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadTabOrder;
   473 Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadTabOrder;
   800             qCritical("Library qttestability load failed!");
   789             qCritical("Library qttestability load failed!");
   801         }
   790         }
   802     }
   791     }
   803 
   792 
   804     //make sure the plugin is loaded
   793     //make sure the plugin is loaded
   805     qt_guiPlatformPlugin();
   794     if (qt_is_gui_used)
       
   795         qt_guiPlatformPlugin();
   806 #endif
   796 #endif
   807 }
   797 }
   808 
   798 
   809 #if defined(Q_WS_X11)
   799 #if defined(Q_WS_X11)
   810 // ### a string literal is a cont char*
   800 // ### a string literal is a cont char*
   938     // qt_init() in qapplication_x11.cpp because of several reasons.
   928     // qt_init() in qapplication_x11.cpp because of several reasons.
   939     // On QWS, the graphics system is set by the QScreen plugin.
   929     // On QWS, the graphics system is set by the QScreen plugin.
   940     graphics_system = QGraphicsSystemFactory::create(graphics_system_name);
   930     graphics_system = QGraphicsSystemFactory::create(graphics_system_name);
   941 #endif
   931 #endif
   942 #ifndef QT_NO_WHEELEVENT
   932 #ifndef QT_NO_WHEELEVENT
   943 #ifdef Q_OS_MAC
       
   944     QApplicationPrivate::wheel_scroll_lines = 1;
       
   945 #else
       
   946     QApplicationPrivate::wheel_scroll_lines = 3;
   933     QApplicationPrivate::wheel_scroll_lines = 3;
   947 #endif
   934 #endif
   948 #endif
   935 
   949 
   936     if (qt_is_gui_used)
   950     initializeMultitouch();
   937         initializeMultitouch();
   951 }
   938 }
   952 
   939 
   953 /*!
   940 /*!
   954     Returns the type of application (\l Tty, GuiClient, or
   941     Returns the type of application (\l Tty, GuiClient, or
   955     GuiServer). The type is set when constructing the QApplication
   942     GuiServer). The type is set when constructing the QApplication
  2083         else if (focus && reason == Qt::ShortcutFocusReason) {
  2070         else if (focus && reason == Qt::ShortcutFocusReason) {
  2084             focus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
  2071             focus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
  2085         }
  2072         }
  2086         QWidget *prev = focus_widget;
  2073         QWidget *prev = focus_widget;
  2087         focus_widget = focus;
  2074         focus_widget = focus;
  2088 
  2075 #ifndef QT_NO_IM
  2089         if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
  2076         if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
  2090             && prev->testAttribute(Qt::WA_InputMethodEnabled))
  2077             && prev->testAttribute(Qt::WA_InputMethodEnabled))
  2091             // Do reset the input context, in case the new focus widget won't accept keyboard input
  2078             // Do reset the input context, in case the new focus widget won't accept keyboard input
  2092             // or it is not created fully yet.
  2079             // or it is not created fully yet.
  2093             || (focus_widget && (!focus_widget->testAttribute(Qt::WA_InputMethodEnabled)
  2080             || (focus_widget && (!focus_widget->testAttribute(Qt::WA_InputMethodEnabled)
  2096             if(qic) {
  2083             if(qic) {
  2097                 qic->reset();
  2084                 qic->reset();
  2098                 qic->setFocusWidget(0);
  2085                 qic->setFocusWidget(0);
  2099             }
  2086             }
  2100         }
  2087         }
       
  2088 #endif //QT_NO_IM
  2101 
  2089 
  2102         if(focus_widget)
  2090         if(focus_widget)
  2103             focus_widget->d_func()->setFocus_sys();
  2091             focus_widget->d_func()->setFocus_sys();
  2104 
  2092 
  2105         if (reason != Qt::NoFocusReason) {
  2093         if (reason != Qt::NoFocusReason) {
  2106 
  2094 
  2107             //send events
  2095             //send events
  2108             if (prev) {
  2096             if (prev) {
  2109 #ifdef QT_KEYPAD_NAVIGATION
  2097 #ifdef QT_KEYPAD_NAVIGATION
  2110                 if (QApplication::keypadNavigationEnabled()) {
  2098                 if (QApplication::keypadNavigationEnabled()) {
  2111                     if (prev->hasEditFocus() && reason != Qt::PopupFocusReason)
  2099                     if (prev->hasEditFocus() && reason != Qt::PopupFocusReason
       
  2100 #ifdef Q_OS_SYMBIAN
       
  2101                             && reason != Qt::ActiveWindowFocusReason
       
  2102 #endif
       
  2103                             )
  2112                         prev->setEditFocus(false);
  2104                         prev->setEditFocus(false);
  2113                 }
  2105                 }
  2114 #endif
  2106 #endif
  2115 #ifndef QT_NO_IM
  2107 #ifndef QT_NO_IM
  2116                 if (focus) {
  2108                 if (focus) {
  2127                 QApplication::sendEvent(prev, &out);
  2119                 QApplication::sendEvent(prev, &out);
  2128                 if (that)
  2120                 if (that)
  2129                     QApplication::sendEvent(that->style(), &out);
  2121                     QApplication::sendEvent(that->style(), &out);
  2130             }
  2122             }
  2131             if(focus && QApplicationPrivate::focus_widget == focus) {
  2123             if(focus && QApplicationPrivate::focus_widget == focus) {
       
  2124 #ifndef QT_NO_IM
  2132                 if (focus->testAttribute(Qt::WA_InputMethodEnabled)) {
  2125                 if (focus->testAttribute(Qt::WA_InputMethodEnabled)) {
  2133                     QInputContext *qic = focus->inputContext();
  2126                     QInputContext *qic = focus->inputContext();
  2134                     if (qic && focus->testAttribute(Qt::WA_WState_Created)
  2127                     if (qic && focus->testAttribute(Qt::WA_WState_Created)
  2135                         && focus->isEnabled())
  2128                         && focus->isEnabled())
  2136                         qic->setFocusWidget(focus);
  2129                         qic->setFocusWidget(focus);
  2137                 }
  2130                 }
       
  2131 #endif //QT_NO_IM
  2138                 QFocusEvent in(QEvent::FocusIn, reason);
  2132                 QFocusEvent in(QEvent::FocusIn, reason);
  2139                 QPointer<QWidget> that = focus;
  2133                 QPointer<QWidget> that = focus;
  2140                 QApplication::sendEvent(focus, &in);
  2134                 QApplication::sendEvent(focus, &in);
  2141                 if (that)
  2135                 if (that)
  2142                     QApplication::sendEvent(that->style(), &in);
  2136                     QApplication::sendEvent(that->style(), &in);
  3636         }
  3630         }
  3637 #endif // !QT_NO_WHEELEVENT || !QT_NO_TABLETEVENT
  3631 #endif // !QT_NO_WHEELEVENT || !QT_NO_TABLETEVENT
  3638     }
  3632     }
  3639 
  3633 
  3640     // walk through parents and check for gestures
  3634     // walk through parents and check for gestures
  3641     if (d->gestureManager) {
  3635     if (qt_gestureManager) {
  3642         if (receiver->isWidgetType()) {
  3636         switch (e->type()) {
  3643             if (d->gestureManager->filterEvent(static_cast<QWidget *>(receiver), e))
  3637         case QEvent::Paint:
  3644                 return true;
  3638         case QEvent::MetaCall:
  3645         } else if (QGesture *gesture = qobject_cast<QGesture *>(receiver)) {
  3639         case QEvent::DeferredDelete:
  3646             if (d->gestureManager->filterEvent(gesture, e))
  3640         case QEvent::DragEnter: case QEvent::DragMove: case QEvent::DragLeave:
  3647                 return true;
  3641         case QEvent::Drop: case QEvent::DragResponse:
       
  3642         case QEvent::ChildAdded: case QEvent::ChildPolished:
       
  3643 #ifdef QT3_SUPPORT
       
  3644         case QEvent::ChildInsertedRequest:
       
  3645         case QEvent::ChildInserted:
       
  3646         case QEvent::LayoutHint:
       
  3647 #endif
       
  3648         case QEvent::ChildRemoved:
       
  3649         case QEvent::UpdateRequest:
       
  3650         case QEvent::UpdateLater:
       
  3651         case QEvent::AccessibilityPrepare:
       
  3652         case QEvent::LocaleChange:
       
  3653         case QEvent::Style:
       
  3654         case QEvent::IconDrag:
       
  3655         case QEvent::StyleChange:
       
  3656         case QEvent::AccessibilityHelp:
       
  3657         case QEvent::AccessibilityDescription:
       
  3658         case QEvent::GraphicsSceneDragEnter:
       
  3659         case QEvent::GraphicsSceneDragMove:
       
  3660         case QEvent::GraphicsSceneDragLeave:
       
  3661         case QEvent::GraphicsSceneDrop:
       
  3662         case QEvent::DynamicPropertyChange:
       
  3663         case QEvent::NetworkReplyUpdated:
       
  3664             break;
       
  3665         default:
       
  3666             if (receiver->isWidgetType()) {
       
  3667                 if (qt_gestureManager->filterEvent(static_cast<QWidget *>(receiver), e))
       
  3668                     return true;
       
  3669             } else {
       
  3670                 // a special case for events that go to QGesture objects.
       
  3671                 // We pass the object to the gesture manager and it'll figure
       
  3672                 // out if it's QGesture or not.
       
  3673                 if (qt_gestureManager->filterEvent(receiver, e))
       
  3674                     return true;
       
  3675             }
  3648         }
  3676         }
  3649     }
  3677     }
  3650 
  3678 
  3651 
  3679 
  3652     // User input and window activation makes tooltips sleep
  3680     // User input and window activation makes tooltips sleep
  4100         while (widget) {
  4128         while (widget) {
  4101             // first, try to deliver the touch event
  4129             // first, try to deliver the touch event
  4102             bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents);
  4130             bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents);
  4103             touchEvent->setWidget(widget);
  4131             touchEvent->setWidget(widget);
  4104             touchEvent->setAccepted(acceptTouchEvents);
  4132             touchEvent->setAccepted(acceptTouchEvents);
       
  4133             QWeakPointer<QWidget> p = widget;
  4105             res = acceptTouchEvents && d->notify_helper(widget, touchEvent);
  4134             res = acceptTouchEvents && d->notify_helper(widget, touchEvent);
  4106             eventAccepted = touchEvent->isAccepted();
  4135             eventAccepted = touchEvent->isAccepted();
  4107             widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted);
  4136             if (p.isNull()) {
       
  4137                 // widget was deleted
       
  4138                 widget = 0;
       
  4139             } else {
       
  4140                 widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted);
       
  4141             }
  4108             touchEvent->spont = false;
  4142             touchEvent->spont = false;
  4109             if (res && eventAccepted) {
  4143             if (res && eventAccepted) {
  4110                 // the first widget to accept the TouchBegin gets an implicit grab.
  4144                 // the first widget to accept the TouchBegin gets an implicit grab.
  4111                 for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
  4145                 for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
  4112                     const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i);
  4146                     const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i);
  4113                     d->widgetForTouchPointId[touchPoint.id()] = widget;
  4147                     d->widgetForTouchPointId[touchPoint.id()] = widget;
  4114                 }
  4148                 }
  4115                 break;
  4149                 break;
  4116             } else if (widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) {
  4150             } else if (p.isNull() || widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) {
  4117                 break;
  4151                 break;
  4118             }
  4152             }
       
  4153             QPoint offset = widget->pos();
  4119             widget = widget->parentWidget();
  4154             widget = widget->parentWidget();
  4120             d->updateTouchPointsForWidget(widget, touchEvent);
  4155             touchEvent->setWidget(widget);
       
  4156             for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) {
       
  4157                 QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i];
       
  4158                 QRectF rect = pt.rect();
       
  4159                 rect.moveCenter(offset);
       
  4160                 pt.d->rect = rect;
       
  4161                 pt.d->startPos = pt.startPos() + offset;
       
  4162                 pt.d->lastPos = pt.lastPos() + offset;
       
  4163             }
  4121         }
  4164         }
  4122 
  4165 
  4123         touchEvent->setAccepted(eventAccepted);
  4166         touchEvent->setAccepted(eventAccepted);
  4124         break;
  4167         break;
  4125     }
  4168     }
  4154     case QEvent::GestureOverride:
  4197     case QEvent::GestureOverride:
  4155     {
  4198     {
  4156         if (receiver->isWidgetType()) {
  4199         if (receiver->isWidgetType()) {
  4157             QWidget *w = static_cast<QWidget *>(receiver);
  4200             QWidget *w = static_cast<QWidget *>(receiver);
  4158             QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(e);
  4201             QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(e);
  4159             QList<QGesture *> allGestures = gestureEvent->allGestures();
  4202             QList<QGesture *> allGestures = gestureEvent->gestures();
  4160 
  4203 
  4161             bool eventAccepted = gestureEvent->isAccepted();
  4204             bool eventAccepted = gestureEvent->isAccepted();
  4162             bool wasAccepted = eventAccepted;
  4205             bool wasAccepted = eventAccepted;
  4163             while (w) {
  4206             while (w) {
  4164                 // send only gestures the widget expects
  4207                 // send only gestures the widget expects
  4165                 QList<QGesture *> gestures;
  4208                 QList<QGesture *> gestures;
  4166                 QWidgetPrivate *wd = w->d_func();
  4209                 QWidgetPrivate *wd = w->d_func();
  4167                 for (int i = 0; i < allGestures.size();) {
  4210                 for (int i = 0; i < allGestures.size();) {
  4168                     QGesture *g = allGestures.at(i);
  4211                     QGesture *g = allGestures.at(i);
  4169                     Qt::GestureType type = g->gestureType();
  4212                     Qt::GestureType type = g->gestureType();
  4170                     if (wd->gestureContext.contains(type)) {
  4213                     QMap<Qt::GestureType, Qt::GestureFlags>::iterator contextit =
       
  4214                             wd->gestureContext.find(type);
       
  4215                     bool deliver = contextit != wd->gestureContext.end() &&
       
  4216                         (g->state() == Qt::GestureStarted || w == receiver ||
       
  4217                          (contextit.value() & Qt::ReceivePartialGestures));
       
  4218                     if (deliver) {
  4171                         allGestures.removeAt(i);
  4219                         allGestures.removeAt(i);
  4172                         gestures.append(g);
  4220                         gestures.append(g);
  4173                     } else {
  4221                     } else {
  4174                         ++i;
  4222                         ++i;
  4175                     }
  4223                     }
  5421         QRectF rect = touchPoint.screenRect();
  5469         QRectF rect = touchPoint.screenRect();
  5422         const QPointF screenPos = rect.center();
  5470         const QPointF screenPos = rect.center();
  5423         const QPointF delta = screenPos - screenPos.toPoint();
  5471         const QPointF delta = screenPos - screenPos.toPoint();
  5424 
  5472 
  5425         rect.moveCenter(widget->mapFromGlobal(screenPos.toPoint()) + delta);
  5473         rect.moveCenter(widget->mapFromGlobal(screenPos.toPoint()) + delta);
  5426         touchPoint.setRect(rect);
  5474         touchPoint.d->rect = rect;
  5427         touchPoint.setStartPos(widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta);
  5475         if (touchPoint.state() == Qt::TouchPointPressed) {
  5428         touchPoint.setLastPos(widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta);
  5476             touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta;
       
  5477             touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta;
       
  5478         }
  5429     }
  5479     }
  5430 }
  5480 }
  5431 
  5481 
  5432 void QApplicationPrivate::initializeMultitouch()
  5482 void QApplicationPrivate::initializeMultitouch()
  5433 {
  5483 {
  5467     typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
  5517     typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
  5468     QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents;
  5518     QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents;
  5469 
  5519 
  5470     for (int i = 0; i < touchPoints.count(); ++i) {
  5520     for (int i = 0; i < touchPoints.count(); ++i) {
  5471         QTouchEvent::TouchPoint touchPoint = touchPoints.at(i);
  5521         QTouchEvent::TouchPoint touchPoint = touchPoints.at(i);
       
  5522         // explicitly detach from the original touch point that we got, so even
       
  5523         // if the touchpoint structs are reused, we will make a copy that we'll
       
  5524         // deliver to the user (which might want to store the struct for later use).
       
  5525         touchPoint.d = touchPoint.d->detach();
  5472 
  5526 
  5473         // update state
  5527         // update state
  5474         QWidget *widget = 0;
  5528         QWeakPointer<QWidget> widget;
  5475         switch (touchPoint.state()) {
  5529         switch (touchPoint.state()) {
  5476         case Qt::TouchPointPressed:
  5530         case Qt::TouchPointPressed:
  5477         {
  5531         {
  5478             if (deviceType == QTouchEvent::TouchPad) {
  5532             if (deviceType == QTouchEvent::TouchPad) {
  5479                 // on touch-pads, send all touch points to the same widget
  5533                 // on touch-pads, send all touch points to the same widget
  5480                 widget = d->widgetForTouchPointId.isEmpty()
  5534                 widget = d->widgetForTouchPointId.isEmpty()
  5481                          ? 0
  5535                          ? QWeakPointer<QWidget>()
  5482                          : d->widgetForTouchPointId.constBegin().value();
  5536                          : d->widgetForTouchPointId.constBegin().value();
  5483             }
  5537             }
  5484 
  5538 
  5485             if (!widget) {
  5539             if (!widget) {
  5486                 // determine which widget this event will go to
  5540                 // determine which widget this event will go to
  5493                     widget = window;
  5547                     widget = window;
  5494             }
  5548             }
  5495 
  5549 
  5496             if (deviceType == QTouchEvent::TouchScreen) {
  5550             if (deviceType == QTouchEvent::TouchScreen) {
  5497                 int closestTouchPointId = d->findClosestTouchPointId(touchPoint.screenPos());
  5551                 int closestTouchPointId = d->findClosestTouchPointId(touchPoint.screenPos());
  5498                 QWidget *closestWidget = d->widgetForTouchPointId.value(closestTouchPointId);
  5552                 QWidget *closestWidget = d->widgetForTouchPointId.value(closestTouchPointId).data();
  5499                 if (closestWidget
  5553                 if (closestWidget
  5500                     && (widget->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget))) {
  5554                     && (widget.data()->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget.data()))) {
  5501                     widget = closestWidget;
  5555                     widget = closestWidget;
  5502                 }
  5556                 }
  5503             }
  5557             }
  5504 
  5558 
  5505             d->widgetForTouchPointId[touchPoint.id()] = widget;
  5559             d->widgetForTouchPointId[touchPoint.id()] = widget;
  5506             touchPoint.setStartScreenPos(touchPoint.screenPos());
  5560             touchPoint.d->startScreenPos = touchPoint.screenPos();
  5507             touchPoint.setLastScreenPos(touchPoint.screenPos());
  5561             touchPoint.d->lastScreenPos = touchPoint.screenPos();
  5508             touchPoint.setStartNormalizedPos(touchPoint.normalizedPos());
  5562             touchPoint.d->startNormalizedPos = touchPoint.normalizedPos();
  5509             touchPoint.setLastNormalizedPos(touchPoint.normalizedPos());
  5563             touchPoint.d->lastNormalizedPos = touchPoint.normalizedPos();
  5510             if (touchPoint.pressure() < qreal(0.))
  5564             if (touchPoint.pressure() < qreal(0.))
  5511                 touchPoint.setPressure(qreal(1.));
  5565                 touchPoint.d->pressure = qreal(1.);
       
  5566 
  5512             d->appCurrentTouchPoints.insert(touchPoint.id(), touchPoint);
  5567             d->appCurrentTouchPoints.insert(touchPoint.id(), touchPoint);
  5513             break;
  5568             break;
  5514         }
  5569         }
  5515         case Qt::TouchPointReleased:
  5570         case Qt::TouchPointReleased:
  5516         {
  5571         {
  5517             widget = d->widgetForTouchPointId.take(touchPoint.id());
  5572             widget = d->widgetForTouchPointId.take(touchPoint.id());
  5518             if (!widget)
  5573             if (!widget)
  5519                 continue;
  5574                 continue;
  5520 
  5575 
  5521             QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.take(touchPoint.id());
  5576             QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.take(touchPoint.id());
  5522             touchPoint.setStartScreenPos(previousTouchPoint.startScreenPos());
  5577             touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos();
  5523             touchPoint.setLastScreenPos(previousTouchPoint.screenPos());
  5578             touchPoint.d->lastScreenPos = previousTouchPoint.screenPos();
  5524             touchPoint.setStartNormalizedPos(previousTouchPoint.startNormalizedPos());
  5579             touchPoint.d->startPos = previousTouchPoint.startPos();
  5525             touchPoint.setLastNormalizedPos(previousTouchPoint.normalizedPos());
  5580             touchPoint.d->lastPos = previousTouchPoint.pos();
       
  5581             touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos();
       
  5582             touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos();
  5526             if (touchPoint.pressure() < qreal(0.))
  5583             if (touchPoint.pressure() < qreal(0.))
  5527                 touchPoint.setPressure(qreal(0.));
  5584                 touchPoint.d->pressure = qreal(0.);
  5528             break;
  5585             break;
  5529         }
  5586         }
  5530         default:
  5587         default:
  5531             widget = d->widgetForTouchPointId.value(touchPoint.id());
  5588             widget = d->widgetForTouchPointId.value(touchPoint.id());
  5532             if (!widget)
  5589             if (!widget)
  5533                 continue;
  5590                 continue;
  5534 
  5591 
  5535             Q_ASSERT(d->appCurrentTouchPoints.contains(touchPoint.id()));
  5592             Q_ASSERT(d->appCurrentTouchPoints.contains(touchPoint.id()));
  5536             QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.value(touchPoint.id());
  5593             QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.value(touchPoint.id());
  5537             touchPoint.setStartScreenPos(previousTouchPoint.startScreenPos());
  5594             touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos();
  5538             touchPoint.setLastScreenPos(previousTouchPoint.screenPos());
  5595             touchPoint.d->lastScreenPos = previousTouchPoint.screenPos();
  5539             touchPoint.setStartNormalizedPos(previousTouchPoint.startNormalizedPos());
  5596             touchPoint.d->startPos = previousTouchPoint.startPos();
  5540             touchPoint.setLastNormalizedPos(previousTouchPoint.normalizedPos());
  5597             touchPoint.d->lastPos = previousTouchPoint.pos();
       
  5598             touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos();
       
  5599             touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos();
  5541             if (touchPoint.pressure() < qreal(0.))
  5600             if (touchPoint.pressure() < qreal(0.))
  5542                 touchPoint.setPressure(qreal(1.));
  5601                 touchPoint.d->pressure = qreal(1.);
  5543             d->appCurrentTouchPoints[touchPoint.id()] = touchPoint;
  5602             d->appCurrentTouchPoints[touchPoint.id()] = touchPoint;
  5544             break;
  5603             break;
  5545         }
  5604         }
  5546         Q_ASSERT(widget != 0);
  5605         Q_ASSERT(widget.data() != 0);
  5547 
  5606 
  5548         // make the *scene* functions return the same as the *screen* functions
  5607         // make the *scene* functions return the same as the *screen* functions
  5549         touchPoint.setSceneRect(touchPoint.screenRect());
  5608         touchPoint.d->sceneRect = touchPoint.screenRect();
  5550         touchPoint.setStartScenePos(touchPoint.startScreenPos());
  5609         touchPoint.d->startScenePos = touchPoint.startScreenPos();
  5551         touchPoint.setLastScenePos(touchPoint.lastScreenPos());
  5610         touchPoint.d->lastScenePos = touchPoint.lastScreenPos();
  5552 
  5611 
  5553         StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[widget];
  5612         StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[widget.data()];
  5554         maskAndPoints.first |= touchPoint.state();
  5613         maskAndPoints.first |= touchPoint.state();
  5555         if (touchPoint.isPrimary())
  5614         if (touchPoint.isPrimary())
  5556             maskAndPoints.first |= Qt::TouchPointPrimary;
  5615             maskAndPoints.first |= Qt::TouchPointPrimary;
  5557         maskAndPoints.second.append(touchPoint);
  5616         maskAndPoints.second.append(touchPoint);
  5558     }
  5617     }
  5615                                             const QList<QTouchEvent::TouchPoint> &touchPoints)
  5674                                             const QList<QTouchEvent::TouchPoint> &touchPoints)
  5616 {
  5675 {
  5617     QApplicationPrivate::translateRawTouchEvent(window, deviceType, touchPoints);
  5676     QApplicationPrivate::translateRawTouchEvent(window, deviceType, touchPoints);
  5618 }
  5677 }
  5619 
  5678 
  5620 /*!
       
  5621     \since 4.6
       
  5622 
       
  5623     Registers the given \a recognizer in the gesture framework and returns a gesture ID
       
  5624     for it.
       
  5625 
       
  5626     The application takes ownership of the \a recognizer and returns the gesture type
       
  5627     ID associated with it. For gesture recognizers which handle custom QGesture
       
  5628     objects (i.e., those which return Qt::CustomGesture in a QGesture::gestureType()
       
  5629     function) the return value is a gesture ID between Qt::CustomGesture and
       
  5630     Qt::LastGestureType, inclusive.
       
  5631 
       
  5632     \sa unregisterGestureRecognizer(), QGestureRecognizer::createGesture(), QGesture
       
  5633 */
       
  5634 Qt::GestureType QApplication::registerGestureRecognizer(QGestureRecognizer *recognizer)
       
  5635 {
       
  5636     return QGestureManager::instance()->registerGestureRecognizer(recognizer);
       
  5637 }
       
  5638 
       
  5639 /*!
       
  5640     \since 4.6
       
  5641 
       
  5642     Unregisters all gesture recognizers of the specified \a type.
       
  5643 
       
  5644     \sa registerGestureRecognizer()
       
  5645 */
       
  5646 void QApplication::unregisterGestureRecognizer(Qt::GestureType type)
       
  5647 {
       
  5648     QGestureManager::instance()->unregisterGestureRecognizer(type);
       
  5649 }
       
  5650 
       
  5651 QT_END_NAMESPACE
  5679 QT_END_NAMESPACE
  5652 
  5680 
  5653 #include "moc_qapplication.cpp"
  5681 #include "moc_qapplication.cpp"