15#include <qwayland-server-wayland.h>
22 : QtWaylandServer::wl_data_source(resource)
41 wl_resource_destroy(resource->handle);
44void DataSourceInterfacePrivate::offer(
const QString &mimeType)
54 & ~(QtWaylandServer::wl_data_device_manager::dnd_action_copy | QtWaylandServer::wl_data_device_manager::dnd_action_move
55 | QtWaylandServer::wl_data_device_manager::dnd_action_ask)) {
56 wl_resource_post_error(resource->handle, error_invalid_action_mask,
"Invalid action mask");
59 DataDeviceManagerInterface::DnDActions supportedActions;
60 if (dnd_actions & QtWaylandServer::wl_data_device_manager::dnd_action_copy) {
61 supportedActions |= DataDeviceManagerInterface::DnDAction::Copy;
63 if (dnd_actions & QtWaylandServer::wl_data_device_manager::dnd_action_move) {
64 supportedActions |= DataDeviceManagerInterface::DnDAction::Move;
66 if (dnd_actions & QtWaylandServer::wl_data_device_manager::dnd_action_ask) {
67 supportedActions |= DataDeviceManagerInterface::DnDAction::Ask;
77 return dataSource->d.get();
80DataSourceInterface::DataSourceInterface(wl_resource *resource)
83 if (d->resource()->version() < WL_DATA_SOURCE_ACTION_SINCE_VERSION) {
84 d->supportedDnDActions = DataDeviceManagerInterface::DnDAction::Copy;
92 d->send_target(mimeType);
93 d->isAccepted = !mimeType.isNull();
98 d->send_send(mimeType, int32_t(fd));
114 if (
auto sourcePrivate = resource_cast<DataSourceInterfacePrivate *>(native)) {
115 return sourcePrivate->q;
122 return d->supportedDnDActions;
127 return d->selectedDndAction;
132 d->dropPerformed =
true;
133 if (d->resource()->version() < WL_DATA_SOURCE_DND_DROP_PERFORMED_SINCE_VERSION) {
136 d->send_dnd_drop_performed();
141 if (d->resource()->version() < WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) {
144 d->send_dnd_finished();
149 return d->dropPerformed;
154 d->selectedDndAction = action;
156 if (d->resource()->version() < WL_DATA_SOURCE_ACTION_SINCE_VERSION) {
159 uint32_t wlAction = QtWaylandServer::wl_data_device_manager::dnd_action_none;
160 if (action == DataDeviceManagerInterface::DnDAction::Copy) {
161 wlAction = QtWaylandServer::wl_data_device_manager::dnd_action_copy;
162 }
else if (action == DataDeviceManagerInterface::DnDAction::Move) {
163 wlAction = QtWaylandServer::wl_data_device_manager::dnd_action_move;
164 }
else if (action == DataDeviceManagerInterface::DnDAction::Ask) {
165 wlAction = QtWaylandServer::wl_data_device_manager::dnd_action_ask;
167 d->send_action(wlAction);
172 d->isCanceled =
true;
174 if (wl_resource_get_version(
resource()) < 3) {
182 return d->isCanceled;
187 return d->resource()->handle;
192 return d->resource()->client();
197 return d->isAccepted;
202 d->isAccepted = accepted;
207 return d->xdgToplevelDrag;
212#include "moc_datasource.cpp"
void mimeTypeOffered(const QString &)
void supportedDragAndDropActionsChanged()
void aboutToBeDestroyed()
Represents the Resource for the wl_data_source interface.
bool isAccepted() const override
bool isDropPerformed() const
virtual ~DataSourceInterface()
void dndFinished() override
wl_resource * resource() const
bool isDndCancelled() const
void dndAction(DataDeviceManagerInterface::DnDAction action) override
void requestData(const QString &mimeType, qint32 fd) override
void setAccepted(bool accepted)
void dropPerformed() override
void dndCancelled() override
wl_client * client() const override
static DataSourceInterface * get(wl_resource *native)
void accept(const QString &mimeType) override
QStringList mimeTypes() const override
DataDeviceManagerInterface::DnDActions supportedDragAndDropActions() const override
DataDeviceManagerInterface::DnDAction selectedDndAction() const override
XdgToplevelDragV1Interface * xdgToplevelDrag() const
DataSourceInterfacePrivate(DataSourceInterface *_q, ::wl_resource *resource)
void data_source_offer(Resource *resource, const QString &mime_type) override
void data_source_destroy(Resource *resource) override
DataDeviceManagerInterface::DnDActions supportedDnDActions
void data_source_set_actions(Resource *resource, uint32_t dnd_actions) override
void data_source_destroy_resource(Resource *resource) override
static DataSourceInterfacePrivate * get(DataSourceInterface *dataSource)