| 1 |
. |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#ifndef QWAYLANDDATADEVICE_H |
| 6 |
#define QWAYLANDDATADEVICE_H |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include <qtwaylandclientglobal_p.h> |
| 20 |
#include <QObject> |
| 21 |
#include <QPointer> |
| 22 |
#include <QPoint> |
| 23 |
|
| 24 |
#include <QtWaylandClient/private/qwayland-wayland.h> |
| 25 |
|
| 26 |
QT_REQUIRE_CONFIG(wayland_datadevice); |
| 27 |
|
| 28 |
QT_BEGIN_NAMESPACE |
| 29 |
|
| 30 |
class QMimeData; |
| 31 |
class QWindow; |
| 32 |
|
| 33 |
namespace QtWaylandClient { |
| 34 |
|
| 35 |
class QWaylandDisplay; |
| 36 |
class QWaylandDataDeviceManager; |
| 37 |
class QWaylandDataOffer; |
| 38 |
class QWaylandDataSource; |
| 39 |
class QWaylandInputDevice; |
| 40 |
class QWaylandWindow; |
| 41 |
|
| 42 |
class QWaylandDataDevice : public QObject, public QtWayland::wl_data_device |
| 43 |
{ |
| 44 |
Q_OBJECT |
| 45 |
public: |
| 46 |
QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWaylandInputDevice *inputDevice); |
| 47 |
~QWaylandDataDevice() override; |
| 48 |
|
| 49 |
QWaylandDataOffer *selectionOffer() const; |
| 50 |
void invalidateSelectionOffer(); |
| 51 |
QWaylandDataSource *selectionSource() const; |
| 52 |
void setSelectionSource(QWaylandDataSource *source); |
| 53 |
|
| 54 |
#if QT_CONFIG(draganddrop) |
| 55 |
QWaylandDataOffer *dragOffer() const; |
| 56 |
void startDrag(QMimeData *mimeData, QWaylandWindow *icon); |
| 57 |
void cancelDrag(); |
| 58 |
#endif |
| 59 |
|
| 60 |
protected: |
| 61 |
void data_device_data_offer(struct ::wl_data_offer *id) override; |
| 62 |
|
| 63 |
#if QT_CONFIG(draganddrop) |
| 64 |
void data_device_drop() override; |
| 65 |
void data_device_enter(uint32_t serial, struct ::wl_surface *surface, wl_fixed_t x, wl_fixed_t y, struct ::wl_data_offer *id) override; |
| 66 |
void data_device_leave() override; |
| 67 |
void data_device_motion(uint32_t time, wl_fixed_t x, wl_fixed_t y) override; |
| 68 |
#endif |
| 69 |
void data_device_selection(struct ::wl_data_offer *id) override; |
| 70 |
|
| 71 |
private Q_SLOTS: |
| 72 |
void selectionSourceCancelled(); |
| 73 |
|
| 74 |
#if QT_CONFIG(draganddrop) |
| 75 |
void dragSourceCancelled(); |
| 76 |
void dragSourceTargetChanged(const QString &mimeType); |
| 77 |
#endif |
| 78 |
|
| 79 |
private: |
| 80 |
#if QT_CONFIG(draganddrop) |
| 81 |
QPoint calculateDragPosition(int x, int y, QWindow *wnd) const; |
| 82 |
#endif |
| 83 |
|
| 84 |
QWaylandDisplay *m_display = nullptr; |
| 85 |
QWaylandInputDevice *m_inputDevice = nullptr; |
| 86 |
uint32_t m_enterSerial = 0; |
| 87 |
QPointer<QWindow> m_dragWindow; |
| 88 |
QPoint m_dragPoint; |
| 89 |
QScopedPointer<QWaylandDataOffer> m_dragOffer; |
| 90 |
QScopedPointer<QWaylandDataOffer> m_selectionOffer; |
| 91 |
QScopedPointer<QWaylandDataSource> m_selectionSource; |
| 92 |
|
| 93 |
QScopedPointer<QWaylandDataSource> m_dragSource; |
| 94 |
}; |
| 95 |
|
| 96 |
} |
| 97 |
|
| 98 |
QT_END_NAMESPACE |
| 99 |
|
| 100 |
#endif |