Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwldataoffer.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "qwldataoffer_p.h"
5
6#include "qwldatadevice_p.h"
7#include "qwldatasource_p.h"
8
9#include <unistd.h>
10
12
13namespace QtWayland
14{
15
16DataOffer::DataOffer(DataSource *dataSource, QtWaylandServer::wl_data_device::Resource *target)
17 : QtWaylandServer::wl_data_offer(target->client(), 0, 1)
18 , m_dataSource(dataSource)
19{
20 // FIXME: connect to dataSource and reset m_dataSource on destroy
21 target->data_device_object->send_data_offer(target->handle, resource()->handle);
22 const auto mimeTypes = dataSource->mimeTypes();
23 for (const QString &mimeType : mimeTypes) {
24 send_offer(mimeType);
25 }
26}
27
31
32void DataOffer::data_offer_accept(Resource *resource, uint32_t serial, const QString &mimeType)
33{
34 Q_UNUSED(resource);
35 Q_UNUSED(serial);
36 if (m_dataSource)
37 m_dataSource->accept(mimeType);
38}
39
40void DataOffer::data_offer_receive(Resource *resource, const QString &mimeType, int32_t fd)
41{
42 Q_UNUSED(resource);
43 if (m_dataSource)
44 m_dataSource->send(mimeType, fd);
45 else
46 close(fd);
47}
48
49void DataOffer::data_offer_destroy(Resource *resource)
50{
51 wl_resource_destroy(resource->handle);
52}
53
55{
56 delete this;
57}
58
59}
60
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
void data_offer_receive(Resource *resource, const QString &mime_type, int32_t fd) override
DataOffer(DataSource *data_source, QtWaylandServer::wl_data_device::Resource *target)
void data_offer_destroy_resource(Resource *resource) override
void data_offer_accept(Resource *resource, uint32_t serial, const QString &mime_type) override
void data_offer_destroy(Resource *resource) override
QList< QString > mimeTypes() const
Combined button and popup list for selecting options.
const char * mimeType
GLuint64 GLenum void * handle
GLenum target
GLuint64 GLenum GLint fd
#define Q_UNUSED(x)