Gesture *GestureHandler::createGesture(const QString &type, int id, const QHash<QString, QVariant>& attrs, bool isComposedGesture) const { // Creamos el gesto sin su acción Gesture *ret; if (isComposedGesture) ret = this->gestureFact->createComposedGesture(type, id, attrs); else ret = this->gestureFact->createSimpleGesture(type, id, attrs); if (ret == NULL) return NULL; // Vemos sobre que ventana se ha ejecutado Window gestureWindow = this->getGestureWindow(attrs.value(GEIS_GESTURE_ATTRIBUTE_CHILD_WINDOW_ID).toInt()); //if (gestureWindow == None) // return NULL; QString appClass = this->getAppClass(gestureWindow); // Creamos y asignamos la acción asociada al gesto ActionTypeEnum::ActionType actionType = this->config->getAssociatedAction(appClass, ret->getType(), ret->getNumFingers(), ret->getDirection()); QString actionSettings = this->config->getAssociatedSettings(appClass, ret->getType(), ret->getNumFingers(), ret->getDirection()); QString timing = this->config->getAssociatedTiming(appClass, ret->getType(), ret->getNumFingers(), ret->getDirection()); ret->setAction(this->actionFact->createAction(actionType, actionSettings, timing, gestureWindow)); // Mostramos los datos sobre el gesto qDebug() << "[+] New gesture:"; qDebug() << "\tType -> " << GestureTypeEnum::getValue(ret->getType()); qDebug() << "\tFingers -> " << ret->getNumFingers(); qDebug() << "\tDirection -> " << GestureDirectionEnum::getValue(ret->getDirection()); qDebug() << "\tAction -> " << ActionTypeEnum::getValue(actionType); qDebug() << "\tTiming -> " << timing; qDebug() << "\tApp Class -> " << appClass; return ret; }
void GestureHandler::executeGestureUpdate(const QString &type, int id, const QHash<QString, QVariant>& attrs) { // If is an update of the current gesture execute it if (this->currentGesture != NULL && this->currentGesture->getId() == id && !this->timerTap->isActive()) { qDebug() << "\tGesture Update" << id << type; this->currentGesture->setAttrs(attrs); this->currentGesture->update(); // If no gesture is running the gesture is a TAP, an unsupported gesture, or in Precise a DRAG } else if (this->currentGesture == NULL) { Gesture *gesture = this->createGesture(type, id, attrs, false); if (gesture != NULL) { this->currentGesture = gesture; // If the gesture is a tap allow to make a tap & hold if (gesture->getType() == GestureTypeEnum::TAP) { this->timerTap->start(); // In Precise the DeltaX and DeltaY attrs in start are 0. Create the Drag here } else if (gesture->getType() == GestureTypeEnum::DRAG) { qDebug() << "\tGesture Start"; this->currentGesture->start(); qDebug() << "\tGesture Update" << id << type; this->currentGesture->update(); } } // If is an update whith the timer running it is a DOUBLE_TAP or a TAP_AND_HOLD } else if (this->currentGesture != NULL && this->timerTap->isActive()) { this->timerTap->stop(); int currentNumFingers = this->currentGesture->getAttrs().value(GEIS_GESTURE_ATTRIBUTE_TOUCHES).toInt(); int newNumFingers = attrs.value(GEIS_GESTURE_ATTRIBUTE_TOUCHES).toInt(); Gesture *gesture = this->createGesture(type, id, attrs, true); if (gesture != NULL && currentNumFingers == newNumFingers) { // TAP_AND_HOLD if (gesture->getType() == GestureTypeEnum::TAP_AND_HOLD) { this->currentGesture = gesture; qDebug() << "\tGesture Start"; this->currentGesture->start(); qDebug() << "\tGesture Update"; this->currentGesture->update(); // DOUBLE_TAP } else if (gesture->getType() == GestureTypeEnum::DOUBLE_TAP) { this->currentGesture = gesture; qDebug() << "\tGesture Start"; this->currentGesture->start(); qDebug() << "\tGesture Update"; this->currentGesture->update(); qDebug() << "\tGesture Finish"; this->currentGesture->finish(); delete this->currentGesture; this->currentGesture = NULL; } } } }