| 1 | // Copyright (C) 2017 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef WLDATADEVICE_H |
| 5 | #define WLDATADEVICE_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtWaylandCompositor/private/qwayland-server-wayland.h> |
| 19 | #include <QtWaylandCompositor/private/qtwaylandcompositorglobal_p.h> |
| 20 | #include <QtWaylandCompositor/QWaylandSeat> |
| 21 | |
| 22 | QT_REQUIRE_CONFIG(wayland_datadevice); |
| 23 | |
| 24 | QT_BEGIN_NAMESPACE |
| 25 | |
| 26 | namespace QtWayland { |
| 27 | |
| 28 | class Compositor; |
| 29 | class DataSource; |
| 30 | class Seat; |
| 31 | class Surface; |
| 32 | |
| 33 | class DataDevice : public QtWaylandServer::wl_data_device |
| 34 | { |
| 35 | public: |
| 36 | DataDevice(QWaylandSeat *seat); |
| 37 | |
| 38 | void setFocus(QWaylandClient *client); |
| 39 | void sourceDestroyed(DataSource *source); |
| 40 | |
| 41 | #if QT_CONFIG(draganddrop) |
| 42 | void setDragFocus(QWaylandSurface *focus, const QPointF &localPosition); |
| 43 | |
| 44 | QWaylandSurface *dragIcon() const; |
| 45 | QWaylandSurface *dragOrigin() const; |
| 46 | |
| 47 | void dragMove(QWaylandSurface *target, const QPointF &pos); |
| 48 | void drop(); |
| 49 | void cancelDrag(); |
| 50 | #endif |
| 51 | |
| 52 | protected: |
| 53 | #if QT_CONFIG(draganddrop) |
| 54 | void data_device_start_drag(Resource *resource, struct ::wl_resource *source, struct ::wl_resource *origin, struct ::wl_resource *icon, uint32_t serial) override; |
| 55 | #endif |
| 56 | void data_device_set_selection(Resource *resource, struct ::wl_resource *source, uint32_t serial) override; |
| 57 | |
| 58 | private: |
| 59 | #if QT_CONFIG(draganddrop) |
| 60 | void setDragIcon(QWaylandSurface *icon); |
| 61 | #endif |
| 62 | |
| 63 | QWaylandCompositor *m_compositor = nullptr; |
| 64 | QWaylandSeat *m_seat = nullptr; |
| 65 | |
| 66 | DataSource *m_selectionSource = nullptr; |
| 67 | |
| 68 | #if QT_CONFIG(draganddrop) |
| 69 | struct ::wl_client *m_dragClient = nullptr; |
| 70 | DataSource *m_dragDataSource = nullptr; |
| 71 | |
| 72 | QWaylandSurface *m_dragFocus = nullptr; |
| 73 | Resource *m_dragFocusResource = nullptr; |
| 74 | |
| 75 | QWaylandSurface *m_dragIcon = nullptr; |
| 76 | QWaylandSurface *m_dragOrigin = nullptr; |
| 77 | #endif |
| 78 | }; |
| 79 | |
| 80 | } |
| 81 | |
| 82 | QT_END_NAMESPACE |
| 83 | |
| 84 | #endif // WLDATADEVICE_H |
| 85 | |