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
qwaylandprimaryselectionv1.cpp
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
8
9#include <QtGui/private/qguiapplication_p.h>
10
11#include <qpa/qplatformclipboard.h>
12
14
15namespace QtWaylandClient {
16
17QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1(QWaylandDisplay *display, uint id, uint version)
18 : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
19 , m_display(display)
20{
21}
22
27
29{
30 return new QWaylandPrimarySelectionDeviceV1(this, seat);
31}
32
33QWaylandPrimarySelectionOfferV1::QWaylandPrimarySelectionOfferV1(QWaylandDisplay *display, ::zwp_primary_selection_offer_v1 *offer)
34 : zwp_primary_selection_offer_v1(offer)
35 , m_display(display)
36 , m_mimeData(new QWaylandMimeData(this))
37{}
38
39void QWaylandPrimarySelectionOfferV1::startReceiving(const QString &mimeType, int fd)
40{
41 receive(mimeType, fd);
42 wl_display_flush(m_display->wl_display());
43}
44
46{
47 m_mimeData->appendFormat(mime_type);
48}
49
50QWaylandPrimarySelectionDeviceV1::QWaylandPrimarySelectionDeviceV1(
51 QWaylandPrimarySelectionDeviceManagerV1 *manager, QWaylandInputDevice *seat)
52 : QtWayland::zwp_primary_selection_device_v1(manager->get_device(seat->wl_seat()))
53 , m_display(manager->display())
54 , m_seat(seat)
55{
56}
57
62
64{
65 if (!m_selectionOffer)
66 return;
67
68 m_selectionOffer.reset();
69 QGuiApplicationPrivate::platformIntegration()->clipboard()->emitChanged(QClipboard::Selection);
70}
71
83
84void QWaylandPrimarySelectionDeviceV1::zwp_primary_selection_device_v1_data_offer(zwp_primary_selection_offer_v1 *offer)
85{
86 new QWaylandPrimarySelectionOfferV1(m_display, offer);
87}
88
89void QWaylandPrimarySelectionDeviceV1::zwp_primary_selection_device_v1_selection(zwp_primary_selection_offer_v1 *id)
90{
91
92 if (id)
93 m_selectionOffer.reset(static_cast<QWaylandPrimarySelectionOfferV1 *>(zwp_primary_selection_offer_v1_get_user_data(id)));
94 else
95 m_selectionOffer.reset();
96
97 QGuiApplicationPrivate::platformIntegration()->clipboard()->emitChanged(QClipboard::Selection);
98}
99
109
114
116{
118 if (!content.isEmpty()) {
119 // Create a sigpipe handler that does nothing, or clients may be forced to terminate
120 // if the pipe is closed in the other end.
121 struct sigaction action, oldAction;
124 action.sa_flags = 0;
125
129 sigaction(SIGPIPE, &oldAction, nullptr);
130 }
131 close(fd);
132}
133
134} // namespace QtWaylandClient
135
136QT_END_NAMESPACE
137
138#include "moc_qwaylandprimaryselectionv1_p.cpp"
QWaylandPrimarySelectionDeviceV1 * createDevice(QWaylandInputDevice *seat)
void startReceiving(const QString &mimeType, int fd) override
void zwp_primary_selection_offer_v1_offer(const QString &mime_type) override
Combined button and popup list for selecting options.