KWin
Loading...
Searching...
No Matches
primaryselectionsource_v1.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
7#include "clientconnection.h"
9#include "utils/resource.h"
10// Qt
11#include <QStringList>
12// Wayland
13#include <qwayland-server-wp-primary-selection-unstable-v1.h>
14// system
15#include <unistd.h>
16
17namespace KWin
18{
19class PrimarySelectionSourceV1InterfacePrivate : public QtWaylandServer::zwp_primary_selection_source_v1
20{
21public:
23
24 QStringList mimeTypes;
26
27protected:
28 void zwp_primary_selection_source_v1_destroy_resource(Resource *resource) override;
29 void zwp_primary_selection_source_v1_offer(Resource *resource, const QString &mime_type) override;
30 void zwp_primary_selection_source_v1_destroy(Resource *resource) override;
31};
32
34 : QtWaylandServer::zwp_primary_selection_source_v1(resource)
35 , q(_q)
36{
37}
38
40 QtWaylandServer::zwp_primary_selection_source_v1::Resource *resource)
41{
42 Q_EMIT q->aboutToBeDestroyed();
43 delete q;
44}
45
47{
48 mimeTypes << mimeType;
49 Q_EMIT q->mimeTypeOffered(mimeType);
50}
51
52void PrimarySelectionSourceV1InterfacePrivate::zwp_primary_selection_source_v1_destroy(QtWaylandServer::zwp_primary_selection_source_v1::Resource *resource)
53{
54 wl_resource_destroy(resource->handle);
55}
56
57PrimarySelectionSourceV1Interface::PrimarySelectionSourceV1Interface(::wl_resource *resource)
58 : d(new PrimarySelectionSourceV1InterfacePrivate(this, resource))
59{
60}
61
63
64void PrimarySelectionSourceV1Interface::requestData(const QString &mimeType, qint32 fd)
65{
66 d->send_send(mimeType, fd);
67 close(fd);
68}
69
71{
72 d->send_cancelled();
73}
74
76{
77 return d->mimeTypes;
78}
79
81{
82 return d->resource()->client();
83}
84
86{
87 if (auto sourcePrivate = resource_cast<PrimarySelectionSourceV1InterfacePrivate *>(native)) {
88 return sourcePrivate->q;
89 }
90 return nullptr;
91}
92
93}
94
95#include "moc_primaryselectionsource_v1.cpp"
void mimeTypeOffered(const QString &)
Represents the Resource for the zwp_primary_selection_source_v1 interface. Lifespan is mapped to the ...
static PrimarySelectionSourceV1Interface * get(wl_resource *native)
void requestData(const QString &mimeType, qint32 fd) override
void zwp_primary_selection_source_v1_destroy(Resource *resource) override
void zwp_primary_selection_source_v1_offer(Resource *resource, const QString &mime_type) override
void zwp_primary_selection_source_v1_destroy_resource(Resource *resource) override
PrimarySelectionSourceV1InterfacePrivate(PrimarySelectionSourceV1Interface *q, ::wl_resource *resource)