1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QWAYLANDPRIMARYSELECTIONV1_P_H
5#define QWAYLANDPRIMARYSELECTIONV1_P_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 <QtWaylandClient/private/qwayland-wp-primary-selection-unstable-v1.h>
19
20#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
21#include <QtWaylandClient/private/qwaylanddataoffer_p.h>
22
23#include <QtCore/QObject>
24
25QT_REQUIRE_CONFIG(wayland_client_primary_selection);
26
27QT_BEGIN_NAMESPACE
28
29class QMimeData;
30
31namespace QtWaylandClient {
32
33class QWaylandInputDevice;
34class QWaylandPrimarySelectionDeviceV1;
35
36class QWaylandPrimarySelectionDeviceManagerV1 : public QtWayland::zwp_primary_selection_device_manager_v1
37{
38public:
39 explicit QWaylandPrimarySelectionDeviceManagerV1(QWaylandDisplay *display, uint id, uint version);
40 ~QWaylandPrimarySelectionDeviceManagerV1();
41 QWaylandPrimarySelectionDeviceV1 *createDevice(QWaylandInputDevice *seat);
42 QWaylandDisplay *display() const { return m_display; }
43
44private:
45 QWaylandDisplay *m_display = nullptr;
46};
47
48class QWaylandPrimarySelectionOfferV1 : public QtWayland::zwp_primary_selection_offer_v1, public QWaylandAbstractDataOffer
49{
50public:
51 explicit QWaylandPrimarySelectionOfferV1(QWaylandDisplay *display, ::zwp_primary_selection_offer_v1 *offer);
52 ~QWaylandPrimarySelectionOfferV1() override { destroy(); }
53 void startReceiving(const QString &mimeType, int fd) override;
54 QMimeData *mimeData() override { return m_mimeData.data(); }
55
56protected:
57 void zwp_primary_selection_offer_v1_offer(const QString &mime_type) override;
58
59private:
60 QWaylandDisplay *m_display = nullptr;
61 QScopedPointer<QWaylandMimeData> m_mimeData;
62};
63
64class Q_WAYLANDCLIENT_EXPORT QWaylandPrimarySelectionSourceV1 : public QObject, public QtWayland::zwp_primary_selection_source_v1
65{
66 Q_OBJECT
67public:
68 explicit QWaylandPrimarySelectionSourceV1(QWaylandPrimarySelectionDeviceManagerV1 *manager, QMimeData *mimeData);
69 ~QWaylandPrimarySelectionSourceV1() override;
70
71 QMimeData *mimeData() const { return m_mimeData; }
72
73Q_SIGNALS:
74 void cancelled();
75
76protected:
77 void zwp_primary_selection_source_v1_send(const QString &mime_type, int32_t fd) override;
78 void zwp_primary_selection_source_v1_cancelled() override { emit cancelled(); }
79
80private:
81 QMimeData *m_mimeData = nullptr;
82};
83
84class QWaylandPrimarySelectionDeviceV1 : public QObject, public QtWayland::zwp_primary_selection_device_v1
85{
86 Q_OBJECT
87 QWaylandPrimarySelectionDeviceV1(QWaylandPrimarySelectionDeviceManagerV1 *manager, QWaylandInputDevice *seat);
88
89public:
90 ~QWaylandPrimarySelectionDeviceV1() override;
91 QWaylandPrimarySelectionOfferV1 *selectionOffer() const { return m_selectionOffer.data(); }
92 void invalidateSelectionOffer();
93 QWaylandPrimarySelectionSourceV1 *selectionSource() const { return m_selectionSource.data(); }
94 void setSelectionSource(QWaylandPrimarySelectionSourceV1 *source);
95
96protected:
97 void zwp_primary_selection_device_v1_data_offer(struct ::zwp_primary_selection_offer_v1 *offer) override;
98 void zwp_primary_selection_device_v1_selection(struct ::zwp_primary_selection_offer_v1 *id) override;
99
100private:
101 QWaylandDisplay *m_display = nullptr;
102 QWaylandInputDevice *m_seat = nullptr;
103 QScopedPointer<QWaylandPrimarySelectionOfferV1> m_selectionOffer;
104 QScopedPointer<QWaylandPrimarySelectionSourceV1> m_selectionSource;
105 friend class QWaylandPrimarySelectionDeviceManagerV1;
106};
107
108} // namespace QtWaylandClient
109
110QT_END_NAMESPACE
111
112#endif // QWAYLANDPRIMARYSELECTIONV1_P_H
113

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtwayland/src/client/qwaylandprimaryselectionv1_p.h