| 1 | // Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> | 
| 2 | // Copyright (C) 2017 The Qt Company Ltd. | 
| 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only | 
| 4 |  | 
| 5 | #ifndef QWAYLANDSURFACE_H | 
| 6 | #define QWAYLANDSURFACE_H | 
| 7 |  | 
| 8 | #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> | 
| 9 | #include <QtWaylandCompositor/qwaylandcompositor.h> | 
| 10 | #include <QtWaylandCompositor/qwaylandcompositorextension.h> | 
| 11 | #include <QtWaylandCompositor/qwaylandclient.h> | 
| 12 | #include <QtWaylandCompositor/qwaylanddrag.h> | 
| 13 |  | 
| 14 | #include <QtCore/QScopedPointer> | 
| 15 | #include <QtGui/QImage> | 
| 16 | #include <QtGui/QWindow> | 
| 17 | #include <QtCore/QVariantMap> | 
| 18 |  | 
| 19 | struct wl_client; | 
| 20 | struct wl_resource; | 
| 21 |  | 
| 22 | QT_BEGIN_NAMESPACE | 
| 23 |  | 
| 24 | class QTouchEvent; | 
| 25 | class QWaylandSurfacePrivate; | 
| 26 | class QWaylandBufferRef; | 
| 27 | class QWaylandView; | 
| 28 | class QWaylandInputMethodControl; | 
| 29 |  | 
| 30 | class QWaylandSurfaceRole | 
| 31 | { | 
| 32 | public: | 
| 33 |     QWaylandSurfaceRole(const QByteArray &n) : m_name(n) {} | 
| 34 |  | 
| 35 |     const QByteArray name() { return m_name; } | 
| 36 |  | 
| 37 | private: | 
| 38 |     QByteArray m_name; | 
| 39 | }; | 
| 40 |  | 
| 41 | class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSurface : public QWaylandObject | 
| 42 | { | 
| 43 |     Q_OBJECT | 
| 44 |     Q_DECLARE_PRIVATE(QWaylandSurface) | 
| 45 |     Q_PROPERTY(QWaylandClient *client READ client CONSTANT) | 
| 46 |     Q_PROPERTY(QRectF sourceGeometry READ sourceGeometry NOTIFY sourceGeometryChanged REVISION(1, 13)) | 
| 47 |     Q_PROPERTY(QSize destinationSize READ destinationSize NOTIFY destinationSizeChanged REVISION(1, 13)) | 
| 48 |     Q_PROPERTY(QSize bufferSize READ bufferSize NOTIFY bufferSizeChanged REVISION(1, 13)) | 
| 49 |     Q_PROPERTY(int bufferScale READ bufferScale NOTIFY bufferScaleChanged) | 
| 50 |     Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation NOTIFY contentOrientationChanged) | 
| 51 |     Q_PROPERTY(QWaylandSurface::Origin origin READ origin NOTIFY originChanged) | 
| 52 |     Q_PROPERTY(bool hasContent READ hasContent NOTIFY hasContentChanged) | 
| 53 |     Q_PROPERTY(bool cursorSurface READ isCursorSurface WRITE markAsCursorSurface NOTIFY cursorSurfaceChanged) | 
| 54 |     Q_PROPERTY(bool inhibitsIdle READ inhibitsIdle NOTIFY inhibitsIdleChanged REVISION(1, 14)) | 
| 55 |     Q_PROPERTY(bool isOpaque READ isOpaque NOTIFY isOpaqueChanged REVISION(6, 4)) | 
| 56 |     Q_MOC_INCLUDE("qwaylanddrag.h" ) | 
| 57 |     Q_MOC_INCLUDE("qwaylandcompositor.h" ) | 
| 58 |  | 
| 59 |     QML_NAMED_ELEMENT(WaylandSurfaceBase) | 
| 60 |     QML_ADDED_IN_VERSION(1, 0) | 
| 61 |     QML_UNCREATABLE("Cannot create instance of WaylandSurfaceBase, use WaylandSurface instead" ) | 
| 62 | public: | 
| 63 |     enum Origin { | 
| 64 |         OriginTopLeft, | 
| 65 |         OriginBottomLeft | 
| 66 |     }; | 
| 67 |     Q_ENUM(Origin) | 
| 68 |  | 
| 69 |     QWaylandSurface(); | 
| 70 |     QWaylandSurface(QWaylandCompositor *compositor, QWaylandClient *client, uint id, int version); | 
| 71 |     ~QWaylandSurface() override; | 
| 72 |  | 
| 73 |     Q_INVOKABLE void initialize(QWaylandCompositor *compositor, QWaylandClient *client, uint id, int version); | 
| 74 |     bool isInitialized() const; | 
| 75 |  | 
| 76 |     QWaylandClient *client() const; | 
| 77 |     ::wl_client *waylandClient() const; | 
| 78 |  | 
| 79 |     bool setRole(QWaylandSurfaceRole *role, wl_resource *errorResource, uint32_t errorCode); | 
| 80 |     QWaylandSurfaceRole *role() const; | 
| 81 |  | 
| 82 |     bool hasContent() const; | 
| 83 |  | 
| 84 |     QRectF sourceGeometry() const; | 
| 85 |     QSize destinationSize() const; | 
| 86 |     QSize bufferSize() const; | 
| 87 |     int bufferScale() const; | 
| 88 |  | 
| 89 |     Qt::ScreenOrientation contentOrientation() const; | 
| 90 |  | 
| 91 |     Origin origin() const; | 
| 92 |  | 
| 93 |     QWaylandCompositor *compositor() const; | 
| 94 |  | 
| 95 |     bool inputRegionContains(const QPoint &p) const; | 
| 96 |     bool inputRegionContains(const QPointF &position) const; | 
| 97 |  | 
| 98 |     Q_INVOKABLE void destroy(); | 
| 99 |     Q_INVOKABLE bool isDestroyed() const; | 
| 100 |  | 
| 101 |     Q_INVOKABLE void frameStarted(); | 
| 102 |     Q_INVOKABLE void sendFrameCallbacks(); | 
| 103 |  | 
| 104 |     QWaylandView *primaryView() const; | 
| 105 |     void setPrimaryView(QWaylandView *view); | 
| 106 |  | 
| 107 |     QList<QWaylandView *> views() const; | 
| 108 |  | 
| 109 |     static QWaylandSurface *fromResource(::wl_resource *resource); | 
| 110 |     struct wl_resource *resource() const; | 
| 111 |  | 
| 112 |     void markAsCursorSurface(bool cursorSurface); | 
| 113 |     bool isCursorSurface() const; | 
| 114 |  | 
| 115 |     bool inhibitsIdle() const; | 
| 116 |     bool isOpaque() const; | 
| 117 |  | 
| 118 | #if QT_CONFIG(im) | 
| 119 |     QWaylandInputMethodControl *inputMethodControl() const; | 
| 120 | #endif | 
| 121 |  | 
| 122 | public Q_SLOTS: | 
| 123 | #if QT_CONFIG(clipboard) | 
| 124 |     void updateSelection(); | 
| 125 | #endif | 
| 126 |  | 
| 127 | protected: | 
| 128 |     QWaylandSurface(QWaylandSurfacePrivate &dptr); | 
| 129 |  | 
| 130 | Q_SIGNALS: | 
| 131 |     void hasContentChanged(); | 
| 132 |     void damaged(const QRegion &rect); | 
| 133 |     void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent); | 
| 134 |     void childAdded(QWaylandSurface *child); | 
| 135 |     Q_REVISION(1, 13) void sourceGeometryChanged(); | 
| 136 |     Q_REVISION(1, 13) void destinationSizeChanged(); | 
| 137 |     Q_REVISION(1, 13) void bufferSizeChanged(); | 
| 138 |     void bufferScaleChanged(); | 
| 139 |     void offsetForNextFrame(const QPoint &offset); | 
| 140 |     void contentOrientationChanged(); | 
| 141 |     void surfaceDestroyed(); | 
| 142 |     void originChanged(); | 
| 143 |     void subsurfacePositionChanged(const QPoint &position); | 
| 144 |     void subsurfacePlaceAbove(QWaylandSurface *sibling); | 
| 145 |     void subsurfacePlaceBelow(QWaylandSurface *sibling); | 
| 146 |     void dragStarted(QWaylandDrag *drag); | 
| 147 |     void cursorSurfaceChanged(); | 
| 148 |     Q_REVISION(14) void inhibitsIdleChanged(); | 
| 149 |     Q_REVISION(6, 4) void isOpaqueChanged(); | 
| 150 |  | 
| 151 |     void configure(bool hasBuffer); | 
| 152 |     void redraw(); | 
| 153 | }; | 
| 154 |  | 
| 155 | QT_END_NAMESPACE | 
| 156 |  | 
| 157 | #endif // QWAYLANDSURFACE_H | 
| 158 |  |