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
qwaylanddrag.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#include "qwaylanddrag.h"
6
7#include <private/qobject_p.h>
8
9#include "qwaylandview.h"
10#include <QtWaylandCompositor/private/qwaylandseat_p.h>
11#include <QtWaylandCompositor/private/qtwaylandcompositorglobal_p.h>
12
13#if QT_CONFIG(wayland_datadevice)
14#include "qwldatadevice_p.h"
15#endif
16
18
20{
21public:
22 QWaylandDragPrivate(QWaylandSeat *seat)
23 : seat(seat)
24 {
25 }
26
28 {
29 return QWaylandSeatPrivate::get(seat)->dataDevice();
30 }
31
33 {
34 return QWaylandSeatPrivate::get(seat)->dataDevice();
35 }
36
37 QWaylandSeat *seat = nullptr;
38};
39
40QWaylandDrag::QWaylandDrag(QWaylandSeat *seat)
41 : QObject(* new QWaylandDragPrivate(seat))
42{
43}
44
45/*!
46 * \qmlproperty WaylandSurface QtWayland.Compositor::WaylandDrag::icon
47 *
48 * This property holds the surface representing the icon of the drag operation,
49 * or \c null if no icon has been set.
50 */
51
52/*!
53 * \property QWaylandDrag::icon
54 *
55 * This property holds the surface representing the icon of the drag operation,
56 * or \nullptr if no icon has been set.
57 */
58QWaylandSurface *QWaylandDrag::icon() const
59{
60 Q_D(const QWaylandDrag);
61
62 const QtWayland::DataDevice *dataDevice = d->dataDevice();
63 if (!dataDevice)
64 return nullptr;
65
66 return dataDevice->dragIcon();
67}
68
69QWaylandSurface *QWaylandDrag::origin() const
70{
71 Q_D(const QWaylandDrag);
72 const QtWayland::DataDevice *dataDevice = d->dataDevice();
73 return dataDevice ? dataDevice->dragOrigin() : nullptr;
74}
75
76QWaylandSeat *QWaylandDrag::seat() const
77{
78 Q_D(const QWaylandDrag);
79 return d->seat;
80}
81
82/*!
83 * \qmlproperty bool QtWayland.Compositor::WaylandDrag::visible
84 *
85 * This property holds whether the drag operation has an icon.
86 *
87 * The value is \c true if an icon has been set for the drag operation;
88 * otherwise \c false.
89 */
90
91/*!
92 * \property QWaylandDrag::visible
93 *
94 * This property holds whether the drag operation has an icon.
95 *
96 * The value is \c true if an icon has been set for the drag operation;
97 * otherwise \c false.
98 */
99bool QWaylandDrag::visible() const
100{
101 Q_D(const QWaylandDrag);
102
103 const QtWayland::DataDevice *dataDevice = d->dataDevice();
104 if (!dataDevice)
105 return false;
106
107 return dataDevice->dragIcon() != nullptr;
108}
109
110void QWaylandDrag::dragMove(QWaylandSurface *target, const QPointF &pos)
111{
112 Q_D(QWaylandDrag);
113 QtWayland::DataDevice *dataDevice = d->dataDevice();
114 if (!dataDevice)
115 return;
116 dataDevice->dragMove(target, pos);
117}
118void QWaylandDrag::drop()
119{
120 Q_D(QWaylandDrag);
121 QtWayland::DataDevice *dataDevice = d->dataDevice();
122 if (!dataDevice)
123 return;
124 dataDevice->drop();
125}
126
127void QWaylandDrag::cancelDrag()
128{
129 Q_D(QWaylandDrag);
130 QtWayland::DataDevice *dataDevice = d->dataDevice();
131 if (!dataDevice)
132 return;
133 dataDevice->cancelDrag();
134}
135
136QT_END_NAMESPACE
137
138#include "moc_qwaylanddrag.cpp"
const QtWayland::DataDevice * dataDevice() const
QtWayland::DataDevice * dataDevice()
QWaylandDragPrivate(QWaylandSeat *seat)
QWaylandSeat * seat
Combined button and popup list for selecting options.