| 1 | /* |
| 2 | * Copyright 2015 Canonical Ltd. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU Lesser General Public License as published by |
| 6 | * the Free Software Foundation; version 3. |
| 7 | * |
| 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 Lesser General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU Lesser General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | |
| 17 | #ifndef TOUCHOWNERSHIPEVENT_P_H |
| 18 | #define TOUCHOWNERSHIPEVENT_P_H |
| 19 | |
| 20 | #include <QtCore/QEvent> |
| 21 | |
| 22 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 23 | #include <LomiriGestures-Qt6/lomirigesturesglobal.h> |
| 24 | #else |
| 25 | #include <LomiriGestures/lomirigesturesglobal.h> |
| 26 | #endif |
| 27 | |
| 28 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 29 | class QEventPoint; |
| 30 | class QPointerEvent; |
| 31 | #endif |
| 32 | |
| 33 | UG_NAMESPACE_BEGIN |
| 34 | /* |
| 35 | When an item get an ownership event for a touch it can grab/steal that touch |
| 36 | with a clean conscience. |
| 37 | */ |
| 38 | class LOMIRIGESTURES_EXPORT TouchOwnershipEvent : public QEvent |
| 39 | { |
| 40 | public: |
| 41 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 42 | TouchOwnershipEvent(int touchId, |
| 43 | bool gained, |
| 44 | QPointerEvent * pointerEvent, |
| 45 | const QEventPoint * point); |
| 46 | #else |
| 47 | TouchOwnershipEvent(int touchId, bool gained); |
| 48 | #endif |
| 49 | |
| 50 | static Type touchOwnershipEventType(); |
| 51 | |
| 52 | /* |
| 53 | Whether ownership was gained (true) or lost (false) |
| 54 | */ |
| 55 | bool gained() const { return m_gained; } |
| 56 | |
| 57 | /* |
| 58 | Id of the touch whose ownership was granted. |
| 59 | */ |
| 60 | int touchId() const { return m_touchId; } |
| 61 | |
| 62 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 63 | /* |
| 64 | QPointerEvent which causes this event to be sent. May be `nullptr` if this |
| 65 | event is not caused by a QPointerEvent. |
| 66 | */ |
| 67 | QPointerEvent * pointerEvent() const { return m_pointerEvent; } |
| 68 | |
| 69 | /* |
| 70 | A QEventPoint which refers to the touch id. This point is guaranteed to |
| 71 | be inside `event()`. May be `nullptr` if `event()` is a `nullptr`. |
| 72 | */ |
| 73 | const QEventPoint * point() const { return m_point; } |
| 74 | #endif |
| 75 | |
| 76 | private: |
| 77 | static Type m_touchOwnershipType; |
| 78 | int m_touchId; |
| 79 | bool m_gained; |
| 80 | |
| 81 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 82 | QPointerEvent * m_pointerEvent; |
| 83 | const QEventPoint * m_point; |
| 84 | #endif |
| 85 | }; |
| 86 | |
| 87 | UG_NAMESPACE_END |
| 88 | |
| 89 | #endif // TOUCHOWNERSHIPEVENT_P_H |