Line |
Branch |
Exec |
Source |
1 |
|
|
/******************************************************************** |
2 |
|
|
Copyright 2014 Martin Gräßlin <mgraesslin@kde.org> |
3 |
|
|
|
4 |
|
|
This library is free software; you can redistribute it and/or |
5 |
|
|
modify it under the terms of the GNU Lesser General Public |
6 |
|
|
License as published by the Free Software Foundation; either |
7 |
|
|
version 2.1 of the License, or (at your option) version 3, or any |
8 |
|
|
later version accepted by the membership of KDE e.V. (or its |
9 |
|
|
successor approved by the membership of KDE e.V.), which shall |
10 |
|
|
act as a proxy defined in Section 6 of version 3 of the license. |
11 |
|
|
|
12 |
|
|
This library is distributed in the hope that it will be useful, |
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 |
|
|
Lesser General Public License for more details. |
16 |
|
|
|
17 |
|
|
You should have received a copy of the GNU Lesser General Public |
18 |
|
|
License along with this library. If not, see <http://www.gnu.org/licenses/>. |
19 |
|
|
*********************************************************************/ |
20 |
|
|
#ifndef WAYLAND_DATA_DEVICE_MANAGER_H |
21 |
|
|
#define WAYLAND_DATA_DEVICE_MANAGER_H |
22 |
|
|
|
23 |
|
|
#include <QObject> |
24 |
|
|
// STD |
25 |
|
|
#include <memory> |
26 |
|
|
|
27 |
|
|
#include <Wrapland/Client/wraplandclient_export.h> |
28 |
|
|
|
29 |
|
|
struct wl_data_device_manager; |
30 |
|
|
|
31 |
|
|
namespace Wrapland |
32 |
|
|
{ |
33 |
|
|
namespace Client |
34 |
|
|
{ |
35 |
|
|
|
36 |
|
|
class EventQueue; |
37 |
|
|
class DataDevice; |
38 |
|
|
class DataSource; |
39 |
|
|
class Seat; |
40 |
|
|
|
41 |
|
|
/** |
42 |
|
|
* @short Wrapper for the wl_data_device_manager interface. |
43 |
|
|
* |
44 |
|
|
* This class provides a convenient wrapper for the wl_data_device_manager interface. |
45 |
|
|
* |
46 |
|
|
* To use this class one needs to interact with the Registry. There are two |
47 |
|
|
* possible ways to create the DataDeviceManager interface: |
48 |
|
|
* @code |
49 |
|
|
* DataDeviceManager *m = registry->createDataDeviceManager(name, version); |
50 |
|
|
* @endcode |
51 |
|
|
* |
52 |
|
|
* This creates the DataDeviceManager and sets it up directly. As an alternative this |
53 |
|
|
* can also be done in a more low level way: |
54 |
|
|
* @code |
55 |
|
|
* DataDeviceManager *m = new DataDeviceManager; |
56 |
|
|
* m->setup(registry->bindDataDeviceManager(name, version)); |
57 |
|
|
* @endcode |
58 |
|
|
* |
59 |
|
|
* The DataDeviceManager can be used as a drop-in replacement for any wl_data_device_manager |
60 |
|
|
* pointer as it provides matching cast operators. |
61 |
|
|
* |
62 |
|
|
* @see Registry |
63 |
|
|
**/ |
64 |
|
|
class WRAPLANDCLIENT_EXPORT DataDeviceManager : public QObject |
65 |
|
|
{ |
66 |
|
|
Q_OBJECT |
67 |
|
|
public: |
68 |
|
|
using device_t = Wrapland::Client::DataDevice; |
69 |
|
|
using source_t = Wrapland::Client::DataSource; |
70 |
|
|
|
71 |
|
|
/** |
72 |
|
|
* Drag and Drop actions supported by DataSource and DataOffer. |
73 |
|
|
* @since 0.0.542 |
74 |
|
|
**/ |
75 |
|
|
enum class DnDAction { |
76 |
|
|
None = 0, |
77 |
|
|
Copy = 1 << 0, |
78 |
|
|
Move = 1 << 1, |
79 |
|
|
Ask = 1 << 2, |
80 |
|
|
}; |
81 |
|
|
Q_DECLARE_FLAGS(DnDActions, DnDAction) |
82 |
|
|
|
83 |
|
|
/** |
84 |
|
|
* Creates a new Compositor. |
85 |
|
|
* Note: after constructing the Compositor it is not yet valid and one needs |
86 |
|
|
* to call setup. In order to get a ready to use Compositor prefer using |
87 |
|
|
* Registry::createCompositor. |
88 |
|
|
**/ |
89 |
|
|
explicit DataDeviceManager(QObject* parent = nullptr); |
90 |
|
|
virtual ~DataDeviceManager(); |
91 |
|
|
|
92 |
|
|
/** |
93 |
|
|
* @returns @c true if managing a wl_data_device_manager. |
94 |
|
|
**/ |
95 |
|
|
bool isValid() const; |
96 |
|
|
/** |
97 |
|
|
* Setup this DataDeviceManager to manage the @p manager. |
98 |
|
|
* When using Registry::createDataDeviceManager there is no need to call this |
99 |
|
|
* method. |
100 |
|
|
**/ |
101 |
|
|
void setup(wl_data_device_manager* manager); |
102 |
|
|
/** |
103 |
|
|
* Releases the wl_data_device_manager interface. |
104 |
|
|
* After the interface has been released the DataDeviceManager instance is no |
105 |
|
|
* longer valid and can be setup with another wl_data_device_manager interface. |
106 |
|
|
**/ |
107 |
|
|
void release(); |
108 |
|
|
|
109 |
|
|
/** |
110 |
|
|
* Sets the @p queue to use for creating a DataSource. |
111 |
|
|
**/ |
112 |
|
|
void setEventQueue(EventQueue* queue); |
113 |
|
|
/** |
114 |
|
|
* @returns The event queue to use for creating a DataSource. |
115 |
|
|
**/ |
116 |
|
|
EventQueue* eventQueue(); |
117 |
|
|
|
118 |
|
|
DataSource* createSource(QObject* parent = nullptr); |
119 |
|
|
|
120 |
|
|
DataDevice* getDevice(Seat* seat, QObject* parent = nullptr); |
121 |
|
|
|
122 |
|
|
operator wl_data_device_manager*(); |
123 |
|
|
operator wl_data_device_manager*() const; |
124 |
|
|
|
125 |
|
|
Q_SIGNALS: |
126 |
|
|
/** |
127 |
|
|
* The corresponding global for this interface on the Registry got removed. |
128 |
|
|
* |
129 |
|
|
* This signal gets only emitted if the Compositor got created by |
130 |
|
|
* Registry::createDataDeviceManager |
131 |
|
|
* |
132 |
|
|
* @since 5.5 |
133 |
|
|
**/ |
134 |
|
|
void removed(); |
135 |
|
|
|
136 |
|
|
private: |
137 |
|
|
class Private; |
138 |
|
|
std::unique_ptr<Private> d; |
139 |
|
|
}; |
140 |
|
|
|
141 |
|
|
} |
142 |
|
|
} |
143 |
|
|
|
144 |
|
24 |
Q_DECLARE_OPERATORS_FOR_FLAGS(Wrapland::Client::DataDeviceManager::DnDActions) |
145 |
|
|
|
146 |
|
|
#endif |
147 |
|
|
|