| 1 | // Copyright (C) 2017 The Qt Company Ltd. | 
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only | 
| 3 |  | 
| 4 | #ifndef QWAYLANDSEAT_H | 
| 5 | #define QWAYLANDSEAT_H | 
| 6 |  | 
| 7 | #include <QtCore/qnamespace.h> | 
| 8 | #include <QtCore/QPoint> | 
| 9 | #include <QtCore/QString> | 
| 10 |  | 
| 11 | #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> | 
| 12 | #include <QtWaylandCompositor/qtwaylandqmlinclude.h> | 
| 13 | #include <QtWaylandCompositor/qwaylandcompositorextension.h> | 
| 14 | #include <QtWaylandCompositor/qwaylandkeyboard.h> | 
| 15 | #include <QtWaylandCompositor/qwaylandview.h> | 
| 16 |  | 
| 17 | QT_BEGIN_NAMESPACE | 
| 18 |  | 
| 19 | class QWaylandCompositor; | 
| 20 | class QWaylandSurface; | 
| 21 | class QKeyEvent; | 
| 22 | class QTouchEvent; | 
| 23 | class QInputEvent; | 
| 24 | class QWaylandSeatPrivate; | 
| 25 | class QWaylandDrag; | 
| 26 | class QWaylandKeyboard; | 
| 27 | class QWaylandPointer; | 
| 28 | class QWaylandTouch; | 
| 29 |  | 
| 30 | class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSeat : public QWaylandObject | 
| 31 | { | 
| 32 |     Q_OBJECT | 
| 33 |     Q_DECLARE_PRIVATE(QWaylandSeat) | 
| 34 |  | 
| 35 | #if QT_CONFIG(draganddrop) | 
| 36 |     Q_PROPERTY(QWaylandDrag *drag READ drag CONSTANT) | 
| 37 |     Q_MOC_INCLUDE("qwaylanddrag.h" ) | 
| 38 | #endif | 
| 39 |     Q_PROPERTY(QWaylandKeymap *keymap READ keymap CONSTANT) | 
| 40 |     Q_MOC_INCLUDE("qwaylandkeymap.h" ) | 
| 41 |     Q_MOC_INCLUDE("qwaylandview.h" ) | 
| 42 |  | 
| 43 |     QML_NAMED_ELEMENT(WaylandSeat) | 
| 44 |     QML_ADDED_IN_VERSION(1, 0) | 
| 45 |     QML_UNCREATABLE("" ) | 
| 46 | public: | 
| 47 |     enum CapabilityFlag { | 
| 48 |         // The order should match the enum WL_SEAT_CAPABILITY_* | 
| 49 |         Pointer = 0x01, | 
| 50 |         Keyboard = 0x02, | 
| 51 |         Touch = 0x04, | 
| 52 |  | 
| 53 |         DefaultCapabilities = Pointer | Keyboard | Touch | 
| 54 |     }; | 
| 55 |     Q_DECLARE_FLAGS(CapabilityFlags, CapabilityFlag) | 
| 56 |     Q_ENUM(CapabilityFlags) | 
| 57 |  | 
| 58 |     QWaylandSeat(QWaylandCompositor *compositor, CapabilityFlags capabilityFlags = DefaultCapabilities); | 
| 59 |     ~QWaylandSeat() override; | 
| 60 |     virtual void initialize(); | 
| 61 |     bool isInitialized() const; | 
| 62 |  | 
| 63 |     void sendMousePressEvent(Qt::MouseButton button); | 
| 64 |     void sendMouseReleaseEvent(Qt::MouseButton button); | 
| 65 |     void sendMouseMoveEvent(QWaylandView *surface , const QPointF &localPos, const QPointF &outputSpacePos = QPointF()); | 
| 66 |     void sendMouseWheelEvent(Qt::Orientation orientation, int delta); | 
| 67 |  | 
| 68 |     void sendKeyPressEvent(uint code); | 
| 69 |     void sendKeyReleaseEvent(uint code); | 
| 70 |  | 
| 71 |     void sendFullKeyEvent(QKeyEvent *event); | 
| 72 |     Q_INVOKABLE void sendKeyEvent(int qtKey, bool pressed); | 
| 73 |  | 
| 74 |     Q_REVISION(6, 7) Q_INVOKABLE void sendUnicodeKeyPressEvent(uint unicode); | 
| 75 |     Q_REVISION(6, 7) Q_INVOKABLE void sendUnicodeKeyReleaseEvent(uint unicode); | 
| 76 |  | 
| 77 |     uint sendTouchPointEvent(QWaylandSurface *surface, int id, const QPointF &point, Qt::TouchPointState state); | 
| 78 |     Q_INVOKABLE uint sendTouchPointPressed(QWaylandSurface *surface, int id, const QPointF &position); | 
| 79 |     Q_INVOKABLE uint sendTouchPointReleased(QWaylandSurface *surface, int id, const QPointF &position); | 
| 80 |     Q_INVOKABLE uint sendTouchPointMoved(QWaylandSurface *surface, int id, const QPointF &position); | 
| 81 |     Q_INVOKABLE void sendTouchFrameEvent(QWaylandClient *client); | 
| 82 |     Q_INVOKABLE void sendTouchCancelEvent(QWaylandClient *client); | 
| 83 |  | 
| 84 |     void sendFullTouchEvent(QWaylandSurface *surface, QTouchEvent *event); | 
| 85 |  | 
| 86 |     QWaylandPointer *pointer() const; | 
| 87 |     //Normally set by the mouse device, | 
| 88 |     //But can be set manually for use with touch or can reset unset the current mouse focus; | 
| 89 |     QWaylandView *mouseFocus() const; | 
| 90 |     void setMouseFocus(QWaylandView *view); | 
| 91 |  | 
| 92 |     QWaylandKeyboard *keyboard() const; | 
| 93 |     QWaylandSurface *keyboardFocus() const; | 
| 94 |     bool setKeyboardFocus(QWaylandSurface *surface); | 
| 95 |     QWaylandKeymap *keymap(); | 
| 96 |  | 
| 97 |     QWaylandTouch *touch() const; | 
| 98 |  | 
| 99 |     QWaylandCompositor *compositor() const; | 
| 100 |  | 
| 101 | #if QT_CONFIG(draganddrop) | 
| 102 |     QWaylandDrag *drag() const; | 
| 103 | #endif | 
| 104 |  | 
| 105 |     QWaylandSeat::CapabilityFlags capabilities() const; | 
| 106 |  | 
| 107 |     virtual bool isOwner(QInputEvent *inputEvent) const; | 
| 108 |  | 
| 109 |     static QWaylandSeat *fromSeatResource(struct ::wl_resource *resource); | 
| 110 |  | 
| 111 | Q_SIGNALS: | 
| 112 |     void mouseFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus); | 
| 113 |     void keyboardFocusChanged(QWaylandSurface *newFocus, QWaylandSurface *oldFocus); | 
| 114 | #if QT_DEPRECATED_SINCE(6, 1) | 
| 115 |     void cursorSurfaceRequest(QWaylandSurface *surface, int hotspotX, int hotspotY); | 
| 116 | #endif | 
| 117 |     void cursorSurfaceRequested(QWaylandSurface *surface, int hotspotX, int hotspotY, QWaylandClient *client); | 
| 118 |  | 
| 119 | private: | 
| 120 |     void sendUnicodeKeyEvent(uint unicode, QEvent::Type type); | 
| 121 |  | 
| 122 |     void handleMouseFocusDestroyed(); | 
| 123 | }; | 
| 124 |  | 
| 125 | Q_DECLARE_OPERATORS_FOR_FLAGS(QWaylandSeat::CapabilityFlags) | 
| 126 |  | 
| 127 | QT_END_NAMESPACE | 
| 128 |  | 
| 129 | #endif // QWAYLANDSEAT_H | 
| 130 |  |