8#include "qwaylandsurface_p.h"
11#if QT_CONFIG(draganddrop)
15#include <QtWaylandCompositor/QWaylandClient>
16#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
17#include <QtWaylandCompositor/private/qwaylandseat_p.h>
18#include <QtWaylandCompositor/private/qwaylandpointer_p.h>
20#include <QtCore/QPointF>
38 Resource *resource = resourceMap().value(focusClient->
client());
43 if (m_selectionSource) {
45 send_selection(resource->handle, offer->resource()->handle);
51 if (m_selectionSource ==
source)
52 m_selectionSource =
nullptr;
55#if QT_CONFIG(draganddrop)
58 if (m_dragFocusResource) {
59 send_leave(m_dragFocusResource->handle);
60 m_dragFocus =
nullptr;
61 m_dragFocusResource =
nullptr;
67 if (!m_dragDataSource && m_dragClient !=
focus->waylandClient())
70 Resource *resource = resourceMap().value(
focus->waylandClient());
75 uint32_t serial = m_compositor->nextSerial();
77 DataOffer *offer = m_dragDataSource ?
new DataOffer(m_dragDataSource, resource) :
nullptr;
79 if (m_dragDataSource && !offer)
82 send_enter(resource->handle, serial,
focus->resource(),
83 wl_fixed_from_double(localPosition.
x()), wl_fixed_from_double(localPosition.
y()),
84 offer->resource()->handle);
87 m_dragFocusResource = resource;
102 if (
target != m_dragFocus)
104 if (!
target || !m_dragFocusResource)
106 uint time = m_compositor->currentTimeMsecs();
107 send_motion(m_dragFocusResource->handle,
time,
108 wl_fixed_from_double(
pos.x()), wl_fixed_from_double(
pos.y()));
111void DataDevice::drop()
113 if (m_dragFocusResource) {
114 send_drop(m_dragFocusResource->handle);
115 setDragFocus(
nullptr,
QPoint());
117 m_dragDataSource->cancel();
119 m_dragOrigin =
nullptr;
120 setDragIcon(
nullptr);
123void DataDevice::cancelDrag()
125 setDragFocus(
nullptr,
QPoint());
128void DataDevice::data_device_start_drag(Resource *resource, struct ::wl_resource *
source, struct ::wl_resource *origin, struct ::wl_resource *
icon, uint32_t serial)
130 m_dragClient = resource->client();
136 Q_EMIT m_dragOrigin->dragStarted(drag);
144 if (
icon == m_dragIcon)
147 Q_EMIT m_seat->drag()->iconChanged();
157 if (m_selectionSource)
158 m_selectionSource->
cancel();
160 m_selectionSource = dataSource;
162 if (m_selectionSource)
166 Resource *resource = focusClient ? resourceMap().value(focusClient->
client()) : 0;
168 if (resource && m_selectionSource) {
170 send_selection(resource->handle, offer->resource()->handle);
171 }
else if (resource) {
172 send_selection(resource->handle,
nullptr);
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
\qmltype WaylandClient \instantiates QWaylandClient \inqmlmodule QtWayland.Compositor
wl_client * client() const
Returns the Wayland client of this QWaylandClient.
static QWaylandCompositorPrivate * get(QWaylandCompositor *compositor)
QWaylandClient * focusClient() const
Returns the client that currently has keyboard focus.
\qmltype WaylandSeat \instantiates QWaylandSeat \inqmlmodule QtWayland.Compositor
QWaylandKeyboard * keyboard() const
Returns the keyboard for this input device.
\qmltype WaylandSurface \instantiates QWaylandSurface \inqmlmodule QtWayland.Compositor
static QWaylandSurface * fromResource(::wl_resource *resource)
Returns the QWaylandSurface corresponding to the Wayland resource resource.
void data_device_set_selection(Resource *resource, struct ::wl_resource *source, uint32_t serial) override
DataDevice(QWaylandSeat *seat)
void sourceDestroyed(DataSource *source)
void setFocus(QWaylandClient *client)
static DataSource * fromResource(struct ::wl_resource *resource)
void setDevice(DataDevice *device)
Combined button and popup list for selecting options.
static QOpenGLCompositor * compositor
GLsizei GLsizei GLchar * source