2 * Copyright (C) 2016 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17#include "TouchGestureArea.h"
19#include <UbuntuGestures/private/touchownershipevent_p.h>
20#include <UbuntuGestures/private/touchregistry_p.h>
21#include <UbuntuGestures/private/unownedtouchevent_p.h>
22// #include "TouchRegistry.h"
23// #include "UnownedTouchEvent.h"
25#include <QGuiApplication>
27#include <private/qquickwindow_p.h>
31#define TOUCHGESTUREAREA_DEBUG 0
33// TODO - understand more about why we lose touch event releases.
34// Workaround for now is to monitor all the touch points from first touch till
35// all have been released; no matter if we've rejected the gesture.
39struct InternalStatus {
42 WaitingForMoreTouches,
43 WaitingForOwnership, //Recognizing,
50TouchGestureArea::Status internalStatusToGestureStatus(int internalStatus) {
51 switch (internalStatus) {
52 case InternalStatus::WaitingForTouch: return TouchGestureArea::WaitingForTouch;
53 case InternalStatus::WaitingForMoreTouches: return TouchGestureArea::Undecided;
54 case InternalStatus::WaitingForOwnership: return TouchGestureArea::Undecided;
55 case InternalStatus::Recognized: return TouchGestureArea::Recognized;
56 case InternalStatus::WaitingForRejection: return TouchGestureArea::Recognized;
57 case InternalStatus::Rejected: return TouchGestureArea::Rejected;
59 return TouchGestureArea::WaitingForTouch;
64#if TOUCHGESTUREAREA_DEBUG
65#define tgaDebug(params) qDebug().nospace() << "[TGA(" << qPrintable(objectName()) << ")] " << params
66#include "DebugHelpers.h"
70const char *statusToString(int status)
72 if (status == InternalStatus::WaitingForTouch) {
73 return "WaitingForTouch";
74 } else if (status == InternalStatus::WaitingForMoreTouches) {
75 return "WaitingForMoreTouches";
76 } else if (status == InternalStatus::WaitingForOwnership) {
77 return "WaitingForOwnership";
78 } else if (status == InternalStatus::Rejected) {
80 } else if (status == InternalStatus::WaitingForRejection) {
81 return "WaitingForRejection";
88QString touchState(Qt::TouchPointState state) {
90 case Qt::TouchPointPressed: return "pressed";
91 case Qt::TouchPointMoved: return "moved";
92 case Qt::TouchPointStationary: return "stationary";
93 case Qt::TouchPointReleased: return "released";
99QString touchesString(const QList<QObject*> touches) {
101 Q_FOREACH(QObject* object, touches) {
102 GestureTouchPoint* touchPoint = qobject_cast<GestureTouchPoint*>(object);
104 str += QStringLiteral("[%1 @ (%2, %3)], ").arg(touchPoint->id())
105 .arg(touchPoint->x())
106 .arg(touchPoint->y());
112QString touchEventString(QTouchEvent* event) {
113 if (!event) return QString();
115 Q_FOREACH(const auto& touchPoint, event->touchPoints()) {
116 str += QStringLiteral("[%1:%2 @ (%3, %4)], ").arg(touchPoint.id())
117 .arg(touchState(touchPoint.state()))
118 .arg(touchPoint.pos().x())
119 .arg(touchPoint.pos().y());
126#else // TOUCHGESTUREAREA_DEBUG
127#define tgaDebug(params) ((void)0)
128#endif // TOUCHGESTUREAREA_DEBUG
130TouchGestureArea::TouchGestureArea(QQuickItem* parent)
132 , m_status(WaitingForTouch)
133 , m_recognitionTimer(nullptr)
135 , m_minimumTouchPoints(1)
136 , m_maximumTouchPoints(INT_MAX)
137 , m_recognitionPeriod(50)
138 , m_releaseRejectPeriod(100)
140 setRecognitionTimer(new Timer(this));
141 m_recognitionTimer->setInterval(m_recognitionPeriod);
142 m_recognitionTimer->setSingleShot(true);
145TouchGestureArea::~TouchGestureArea()
148 qDeleteAll(m_liveTouchPoints);
149 m_liveTouchPoints.clear();
150 qDeleteAll(m_cachedTouchPoints);
151 m_cachedTouchPoints.clear();
154bool TouchGestureArea::event(QEvent *event)
156 // Process unowned touch events (handles update/release for incomplete gestures)
157 if (event->type() == TouchOwnershipEvent::touchOwnershipEventType()) {
158 touchOwnershipEvent(static_cast<TouchOwnershipEvent*>(event));
160 } else if (event->type() == UnownedTouchEvent::unownedTouchEventType()) {
161 unownedTouchEvent(static_cast<UnownedTouchEvent*>(event)->touchEvent());
165 return QQuickItem::event(event);
168void TouchGestureArea::touchOwnershipEvent(TouchOwnershipEvent *event)
170 int touchId = event->touchId();
171 tgaDebug("touchOwnershipEvent - id:" << touchId << ", gained:" << event->gained());
173 if (event->gained()) {
174 grabTouchPoints(QVector<int>() << touchId);
175 m_candidateTouches.remove(touchId);
176 TouchRegistry::instance()->addTouchWatcher(touchId, this);
177 m_watchedTouches.insert(touchId);
179 if (m_watchedTouches.count() >= m_minimumTouchPoints) {
180 setInternalStatus(InternalStatus::Recognized);
187void TouchGestureArea::touchEvent(QTouchEvent *event)
189 if (!isEnabled() || !isVisible()) {
190 tgaDebug(QString("NOT ENABLED touchEvent(%1) %2").arg(statusToString(m_status)).arg(touchEventString(event)));
191 QQuickItem::touchEvent(event);
195 tgaDebug(QString("touchEvent(%1) %2").arg(statusToString(m_status)).arg(touchEventString(event)));
198 case InternalStatus::WaitingForTouch:
199 touchEvent_waitingForTouch(event);
201 case InternalStatus::WaitingForMoreTouches:
202 touchEvent_waitingForMoreTouches(event);
204 case InternalStatus::WaitingForOwnership:
205 touchEvent_waitingForOwnership(event);
207 case InternalStatus::Recognized:
208 case InternalStatus::WaitingForRejection:
209 touchEvent_recognized(event);
211 case InternalStatus::Rejected:
212 touchEvent_rejected(event);
214 default: // Recognized:
218 updateTouchPoints(event);
221void TouchGestureArea::touchEvent_waitingForTouch(QTouchEvent *event)
223 Q_FOREACH(const QTouchEvent::TouchPoint& touchPoint, event->touchPoints()) {
224 Qt::TouchPointState touchPointState = touchPoint.state();
225 int touchId = touchPoint.id();
227 if (touchPointState == Qt::TouchPointPressed) {
228 if (!m_candidateTouches.contains(touchId)) {
229 TouchRegistry::instance()->addCandidateOwnerForTouch(touchId, this);
230 m_candidateTouches.insert(touchId);
236 if (m_candidateTouches.count() > m_maximumTouchPoints) {
238 } else if (m_candidateTouches.count() >= m_minimumTouchPoints) {
239 setInternalStatus(InternalStatus::WaitingForOwnership);
241 QSet<int> tmpCandidates(m_candidateTouches);
242 Q_FOREACH(int candidateTouchId, tmpCandidates) {
243 TouchRegistry::instance()->requestTouchOwnership(candidateTouchId, this);
245 // We accept the gesture; so don't pass to lower items
247 } else if (m_candidateTouches.count() > 0) {
248 setInternalStatus(InternalStatus::WaitingForMoreTouches);
252void TouchGestureArea::touchEvent_waitingForMoreTouches(QTouchEvent *event)
254 Q_FOREACH(const QTouchEvent::TouchPoint& touchPoint, event->touchPoints()) {
255 Qt::TouchPointState touchPointState = touchPoint.state();
256 int touchId = touchPoint.id();
258 if (touchPointState == Qt::TouchPointPressed) {
259 if (!m_candidateTouches.contains(touchId)) {
260 TouchRegistry::instance()->addCandidateOwnerForTouch(touchId, this);
261 m_candidateTouches.insert(touchId);
267 if (m_candidateTouches.count() > m_maximumTouchPoints) {
269 } else if (m_candidateTouches.count() >= m_minimumTouchPoints) {
270 setInternalStatus(InternalStatus::WaitingForOwnership);
272 QSet<int> tmpCandidates(m_candidateTouches);
273 Q_FOREACH(int candidateTouchId, tmpCandidates) {
274 TouchRegistry::instance()->requestTouchOwnership(candidateTouchId, this);
276 // We accept the gesture; so don't pass to lower items
281void TouchGestureArea::touchEvent_waitingForOwnership(QTouchEvent *event)
283 Q_FOREACH(const QTouchEvent::TouchPoint& touchPoint, event->touchPoints()) {
284 Qt::TouchPointState touchPointState = touchPoint.state();
285 int touchId = touchPoint.id();
287 if (touchPointState == Qt::TouchPointPressed) {
288 if (!m_watchedTouches.contains(touchId)) {
289 TouchRegistry::instance()->addTouchWatcher(touchId, this);
290 m_watchedTouches.insert(touchId);
296void TouchGestureArea::touchEvent_recognized(QTouchEvent *event)
298 Q_FOREACH(const QTouchEvent::TouchPoint& touchPoint, event->touchPoints()) {
299 Qt::TouchPointState touchPointState = touchPoint.state();
300 int touchId = touchPoint.id();
302 if (touchPointState == Qt::TouchPointPressed) {
303 if (!m_watchedTouches.contains(touchId)) {
304 TouchRegistry::instance()->addTouchWatcher(touchId, this);
305 m_watchedTouches.insert(touchId);
310 if (m_watchedTouches.count() > m_maximumTouchPoints) {
312 } else if (m_watchedTouches.count() >= m_minimumTouchPoints &&
313 m_status==InternalStatus::WaitingForRejection) {
314 setInternalStatus(InternalStatus::Recognized);
318void TouchGestureArea::touchEvent_rejected(QTouchEvent *event)
320 Q_FOREACH(const QTouchEvent::TouchPoint& touchPoint, event->touchPoints()) {
321 Qt::TouchPointState touchPointState = touchPoint.state();
322 int touchId = touchPoint.id();
324 if (touchPointState == Qt::TouchPointPressed) {
325 if (!m_watchedTouches.contains(touchId)) {
326 TouchRegistry::instance()->addTouchWatcher(touchId, this);
327 m_watchedTouches.insert(touchId);
332 // If this event is a new touch, ignore it and let the item below have it.
333 // We won't recognize any new touch until the whole current gesture is done
334 // i.e. we're in WaitingForTouch state.
335 // And even if it isn't, just ignore it anyway; we don't care about it.
339void TouchGestureArea::unownedTouchEvent(QTouchEvent *unownedTouchEvent)
341 tgaDebug(QString("unownedTouchEvent(%1) %2").arg(statusToString(m_status)).arg(touchEventString(unownedTouchEvent)));
343 // Only monitor unowned touch events for presses/releases
344 if ((unownedTouchEvent->touchPointStates() & (Qt::TouchPointPressed|Qt::TouchPointReleased)) == 0) {
349 case InternalStatus::WaitingForTouch:
351 case InternalStatus::WaitingForMoreTouches:
352 unownedTouchEvent_waitingForMoreTouches(unownedTouchEvent);
355 case InternalStatus::WaitingForOwnership:
356 unownedTouchEvent_waitingForOwnership(unownedTouchEvent);
358 case InternalStatus::Recognized:
359 case InternalStatus::WaitingForRejection:
360 unownedTouchEvent_recognised(unownedTouchEvent);
362 case InternalStatus::Rejected:
363 unownedTouchEvent_rejected(unownedTouchEvent);
369 updateTouchPoints(unownedTouchEvent);
372void TouchGestureArea::unownedTouchEvent_waitingForMoreTouches(QTouchEvent *event)
374 Q_FOREACH(const QTouchEvent::TouchPoint& touchPoint, event->touchPoints()) {
375 Qt::TouchPointState touchPointState = touchPoint.state();
376 int touchId = touchPoint.id();
378 if (touchPointState == Qt::TouchPointReleased) {
379 if (m_candidateTouches.contains(touchId)) {
380 TouchRegistry::instance()->removeCandidateOwnerForTouch(touchId, this);
381 m_candidateTouches.remove(touchId);
386 if (m_candidateTouches.isEmpty()) {
387 setInternalStatus(InternalStatus::WaitingForTouch);
391void TouchGestureArea::unownedTouchEvent_waitingForOwnership(QTouchEvent *event)
393 Q_FOREACH(const QTouchEvent::TouchPoint& touchPoint, event->touchPoints()) {
394 Qt::TouchPointState touchPointState = touchPoint.state();
395 int touchId = touchPoint.id();
397 if (touchPointState == Qt::TouchPointReleased) {
398 if (m_candidateTouches.contains(touchId)) {
399 TouchRegistry::instance()->removeCandidateOwnerForTouch(touchId, this);
400 m_candidateTouches.remove(touchId);
402 if (m_watchedTouches.contains(touchId)) {
403 m_watchedTouches.remove(touchId);
408 if (m_candidateTouches.count() + m_watchedTouches.count() == 0) {
409 setInternalStatus(InternalStatus::WaitingForTouch);
413void TouchGestureArea::unownedTouchEvent_recognised(QTouchEvent *event)
415 Q_FOREACH(const QTouchEvent::TouchPoint& touchPoint, event->touchPoints()) {
416 Qt::TouchPointState touchPointState = touchPoint.state();
417 int touchId = touchPoint.id();
419 if (touchPointState == Qt::TouchPointReleased) {
420 if (m_watchedTouches.contains(touchId)) {
421 m_watchedTouches.remove(touchId);
426 if (m_watchedTouches.count() < m_minimumTouchPoints && m_status==InternalStatus::Recognized) {
427 setInternalStatus(InternalStatus::WaitingForRejection);
431void TouchGestureArea::unownedTouchEvent_rejected(QTouchEvent *event)
433 Q_FOREACH(const QTouchEvent::TouchPoint& touchPoint, event->touchPoints()) {
434 Qt::TouchPointState touchPointState = touchPoint.state();
435 int touchId = touchPoint.id();
437 if (touchPointState == Qt::TouchPointPressed) {
438 if (!m_watchedTouches.contains(touchId)) {
439 TouchRegistry::instance()->addTouchWatcher(touchId, this);
440 m_watchedTouches.insert(touchId);
443 if (touchPointState == Qt::TouchPointReleased) {
444 if (m_watchedTouches.contains(touchId)) {
445 m_watchedTouches.remove(touchId);
450 if (m_watchedTouches.isEmpty()) {
451 setInternalStatus(InternalStatus::WaitingForTouch);
455void TouchGestureArea::updateTouchPoints(QTouchEvent *touchEvent)
461 const int dragThreshold = qApp->styleHints()->startDragDistance();
462 const int dragVelocity = qApp->styleHints()->startDragVelocity();
465 bool updateable = m_status != InternalStatus::WaitingForRejection;
467 Q_FOREACH(const QTouchEvent::TouchPoint& touchPoint, touchEvent->touchPoints()) {
468 Qt::TouchPointState touchPointState = touchPoint.state();
469 int touchId = touchPoint.id();
471 if (touchPointState & Qt::TouchPointReleased) {
472 GestureTouchPoint* gtp = m_liveTouchPoints.value(touchId);
475 gtp->setPos(touchPoint.pos());
476 gtp->setPressed(false);
477 m_releasedTouchPoints.append(gtp);
478 m_liveTouchPoints.remove(touchId);
481 if (m_cachedTouchPoints.contains(touchId)) {
482 GestureTouchPoint* cachedPoint = m_cachedTouchPoints.take(touchId);
483 cachedPoint->deleteLater();
488 GestureTouchPoint* gtp = m_liveTouchPoints.value(touchPoint.id(), nullptr);
490 gtp = addTouchPoint(&touchPoint);
491 m_pressedTouchPoints.append(gtp);
494 if (m_cachedTouchPoints.contains(touchId)) {
495 m_cachedTouchPoints[touchId]->setPos(touchPoint.pos());
497 m_cachedTouchPoints[touchId] = new GestureTouchPoint(*gtp);
501 } else if (touchPointState & Qt::TouchPointMoved) {
502 gtp->setPos(touchPoint.pos());
503 m_movedTouchPoints.append(gtp);
506 const QPointF ¤tPos = touchPoint.scenePos();
507 const QPointF &startPos = touchPoint.startScenePos();
509 bool overDragThreshold = false;
510 bool supportsVelocity = (touchEvent->device()->capabilities() & QTouchDevice::Velocity) && dragVelocity;
511 overDragThreshold |= qAbs(currentPos.x() - startPos.x()) > dragThreshold ||
512 qAbs(currentPos.y() - startPos.y()) > dragThreshold;
513 if (supportsVelocity) {
514 QVector2D velocityVec = touchPoint.velocity();
515 overDragThreshold |= qAbs(velocityVec.x()) > dragVelocity;
516 overDragThreshold |= qAbs(velocityVec.y()) > dragVelocity;
519 if (overDragThreshold) {
520 gtp->setDragging(true);
524 if (m_cachedTouchPoints.contains(touchId)) {
525 m_cachedTouchPoints[touchId]->setPos(touchPoint.pos());
526 if (overDragThreshold) {
527 m_cachedTouchPoints[touchId]->setDragging(true);
536 if (!dragging() && m_status == InternalStatus::Recognized) {
537 bool allWantDrag = !m_liveTouchPoints.isEmpty();
538 Q_FOREACH(const auto &point, m_liveTouchPoints) {
539 allWantDrag &= point->dragging();
541 // only dragging if all points are dragging.
548 if (m_liveTouchPoints.isEmpty()) {
549 if (!dragging()) Q_EMIT clicked();
552 tgaDebug("Released " << touchesString(m_releasedTouchPoints));
553 Q_EMIT released(m_releasedTouchPoints);
556 tgaDebug("Pressed " << touchesString(m_pressedTouchPoints));
557 Q_EMIT pressed(m_pressedTouchPoints);
560 tgaDebug("Updated " << touchesString(m_movedTouchPoints));
561 Q_EMIT updated(m_movedTouchPoints);
563 if (added || ended || moved) {
564 Q_EMIT touchPointsUpdated();
569void TouchGestureArea::clearTouchLists()
571 Q_FOREACH (QObject *gtp, m_releasedTouchPoints) {
574 m_releasedTouchPoints.clear();
575 m_pressedTouchPoints.clear();
576 m_movedTouchPoints.clear();
579void TouchGestureArea::setInternalStatus(uint newStatus)
581 if (newStatus == m_status)
584 uint oldStatus = m_status;
586 m_status = newStatus;
587 Q_EMIT statusChanged(status());
589 if (oldStatus == InternalStatus::WaitingForMoreTouches || oldStatus == InternalStatus::WaitingForRejection) {
590 m_recognitionTimer->stop();
593 tgaDebug(statusToString(oldStatus) << " -> " << statusToString(newStatus));
596 case InternalStatus::WaitingForTouch:
597 resyncCachedTouchPoints();
599 case InternalStatus::WaitingForMoreTouches:
600 m_recognitionTimer->setInterval(m_recognitionPeriod);
601 m_recognitionTimer->start();
603 case InternalStatus::Recognized:
604 resyncCachedTouchPoints();
606 case InternalStatus::WaitingForRejection:
607 m_recognitionTimer->setInterval(m_releaseRejectPeriod);
608 m_recognitionTimer->start();
610 case InternalStatus::Rejected:
611 resyncCachedTouchPoints();
619void TouchGestureArea::setRecognitionTimer(AbstractTimer *timer)
622 bool timerWasRunning = false;
623 bool wasSingleShot = false;
625 // can be null when called from the constructor
626 if (m_recognitionTimer) {
627 interval = m_recognitionTimer->interval();
628 timerWasRunning = m_recognitionTimer->isRunning();
629 if (m_recognitionTimer->parent() == this) {
630 delete m_recognitionTimer;
634 m_recognitionTimer = timer;
635 timer->setInterval(interval);
636 timer->setSingleShot(wasSingleShot);
637 connect(timer, SIGNAL(timeout()),
638 this, SLOT(rejectGesture()));
639 if (timerWasRunning) {
640 m_recognitionTimer->start();
644int TouchGestureArea::status() const
646 return internalStatusToGestureStatus(m_status);
649bool TouchGestureArea::dragging() const
654QQmlListProperty<GestureTouchPoint> TouchGestureArea::touchPoints()
656 return QQmlListProperty<GestureTouchPoint>(this,
658 TouchGestureArea::touchPoint_count,
659 TouchGestureArea::touchPoint_at);
662int TouchGestureArea::minimumTouchPoints() const
664 return m_minimumTouchPoints;
667void TouchGestureArea::setMinimumTouchPoints(int value)
669 if (m_minimumTouchPoints != value) {
670 m_minimumTouchPoints = value;
671 Q_EMIT minimumTouchPointsChanged(value);
675int TouchGestureArea::maximumTouchPoints() const
677 return m_maximumTouchPoints;
680void TouchGestureArea::setMaximumTouchPoints(int value)
682 if (m_maximumTouchPoints != value) {
683 m_maximumTouchPoints = value;
684 Q_EMIT maximumTouchPointsChanged(value);
688int TouchGestureArea::recognitionPeriod() const
690 return m_recognitionPeriod;
693void TouchGestureArea::setRecognitionPeriod(int value)
695 if (value != m_recognitionPeriod) {
696 m_recognitionPeriod = value;
697 Q_EMIT recognitionPeriodChanged(value);
701int TouchGestureArea::releaseRejectPeriod() const
703 return m_releaseRejectPeriod;
706void TouchGestureArea::setReleaseRejectPeriod(int value)
708 if (value != m_releaseRejectPeriod) {
709 m_releaseRejectPeriod = value;
710 Q_EMIT releaseRejectPeriodChanged(value);
714void TouchGestureArea::rejectGesture()
716 tgaDebug("rejectGesture");
719 Q_FOREACH(int touchId, m_candidateTouches) {
720 TouchRegistry::instance()->removeCandidateOwnerForTouch(touchId, this);
723 // Monitor the candidates
724 Q_FOREACH(int touchId, m_candidateTouches) {
725 TouchRegistry::instance()->addTouchWatcher(touchId, this);
726 m_watchedTouches.insert(touchId);
728 m_candidateTouches.clear();
730 if (m_watchedTouches.isEmpty()) {
731 setInternalStatus(InternalStatus::WaitingForTouch);
733 setInternalStatus(InternalStatus::Rejected);
737void TouchGestureArea::resyncCachedTouchPoints()
746 QMutableHashIterator<int, GestureTouchPoint*> removeIter(m_cachedTouchPoints);
747 while(removeIter.hasNext()) {
749 if (!m_liveTouchPoints.contains(removeIter.key())) {
750 m_releasedTouchPoints.append(removeIter.value());
756 // list of adds/moves
757 Q_FOREACH(GestureTouchPoint* touchPoint, m_liveTouchPoints) {
758 if (m_cachedTouchPoints.contains(touchPoint->id())) {
759 GestureTouchPoint* cachedPoint = m_cachedTouchPoints[touchPoint->id()];
761 if (*cachedPoint != *touchPoint) {
762 *cachedPoint = *touchPoint;
763 m_movedTouchPoints.append(touchPoint);
767 m_cachedTouchPoints.insert(touchPoint->id(), new GestureTouchPoint(*touchPoint));
768 m_pressedTouchPoints.append(touchPoint);
774 if (m_cachedTouchPoints.isEmpty()) {
775 if (!dragging()) Q_EMIT clicked();
778 tgaDebug("Cached Release " << touchesString(m_releasedTouchPoints));
779 Q_EMIT released(m_releasedTouchPoints);
782 tgaDebug("Cached Press " << touchesString(m_pressedTouchPoints));
783 Q_EMIT pressed(m_pressedTouchPoints);
786 tgaDebug("Cached Update " << touchesString(m_movedTouchPoints));
787 Q_EMIT updated(m_movedTouchPoints);
789 if (added || ended || moved) Q_EMIT touchPointsUpdated();
792int TouchGestureArea::touchPoint_count(QQmlListProperty<GestureTouchPoint> *list)
794 TouchGestureArea *q = static_cast<TouchGestureArea*>(list->object);
795 return q->m_cachedTouchPoints.count();
798GestureTouchPoint *TouchGestureArea::touchPoint_at(QQmlListProperty<GestureTouchPoint> *list, int index)
800 TouchGestureArea *q = static_cast<TouchGestureArea*>(list->object);
801 return (q->m_cachedTouchPoints.begin()+index).value();
804GestureTouchPoint* TouchGestureArea::addTouchPoint(QTouchEvent::TouchPoint const* tp)
806 GestureTouchPoint* gtp = new GestureTouchPoint();
807 gtp->setId(tp->id());
808 gtp->setPressed(true);
809 gtp->setPos(tp->pos());
810 m_liveTouchPoints.insert(tp->id(), gtp);
814void TouchGestureArea::itemChange(ItemChange change, const ItemChangeData &value)
816 if (change == QQuickItem::ItemSceneChange) {
817 if (value.window != nullptr) {
818 value.window->installEventFilter(TouchRegistry::instance());
823void TouchGestureArea::setDragging(bool dragging)
825 if (m_dragging == dragging)
828 tgaDebug("setDragging " << dragging);
830 m_dragging = dragging;
831 Q_EMIT draggingChanged(m_dragging);
834void GestureTouchPoint::setId(int id)
842void GestureTouchPoint::setPressed(bool pressed)
844 if (m_pressed == pressed)
847 Q_EMIT pressedChanged();
850void GestureTouchPoint::setX(qreal x)
858void GestureTouchPoint::setY(qreal y)
866void GestureTouchPoint::setDragging(bool dragging)
868 if (m_dragging == dragging)
871 m_dragging = dragging;
872 Q_EMIT draggingChanged();
875void GestureTouchPoint::setPos(const QPointF &pos)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list