Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwldatasource.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
8#include <QtWaylandCompositor/private/qwaylandutils_p.h>
9
10#include <unistd.h>
11#include <QtWaylandCompositor/private/wayland-wayland-server-protocol.h>
12
13QT_BEGIN_NAMESPACE
14
15namespace QtWayland {
16
17DataSource::DataSource(struct wl_client *client, uint32_t id, uint32_t time)
18 : QtWaylandServer::wl_data_source(client, id, 1)
19 , m_time(time)
20{
21}
22
24{
25 if (m_manager)
26 m_manager->sourceDestroyed(this);
27 if (m_device)
28 m_device->sourceDestroyed(this);
29}
30
32{
33 return m_time;
34}
35
37{
38 return m_mimeTypes;
39}
40
41void DataSource::accept(const QString &mimeType)
42{
43 send_target(mimeType);
44}
45
46void DataSource::send(const QString &mimeType, int fd)
47{
48 send_send(mimeType, fd);
49 close(fd);
50}
51
53{
54 send_cancelled();
55}
56
58{
59 m_manager = mgr;
60}
61
63{
64 m_device = device;
65}
66
67DataSource *DataSource::fromResource(struct ::wl_resource *resource)
68{
69 return QtWayland::fromResource<DataSource *>(resource);
70}
71
72void DataSource::data_source_offer(Resource *, const QString &mime_type)
73{
74 m_mimeTypes.append(mime_type);
75}
76
77void DataSource::data_source_destroy(Resource *resource)
78{
79 wl_resource_destroy(resource->handle);
80}
81
82void DataSource::data_source_destroy_resource(QtWaylandServer::wl_data_source::Resource *resource)
83{
84 Q_UNUSED(resource);
85 delete this;
86}
87
88}
89
90QT_END_NAMESPACE
void sourceDestroyed(DataSource *source)
void sourceDestroyed(DataSource *source)
void send(const QString &mimeType, int fd)
uint32_t time() const
void setManager(DataDeviceManager *mgr)
void data_source_destroy_resource(Resource *resource) override
void data_source_offer(Resource *resource, const QString &mime_type) override
void setDevice(DataDevice *device)
void accept(const QString &mimeType)
void data_source_destroy(Resource *resource) override
QList< QString > mimeTypes() const