kwin/src/wayland/datadevice_interface_p.h
David Redondo 0aaed33c66 Move drag logic to seat and introduce SeatInterface::startDrag
A dataDevice has a request to start a drag with multiple parameters.
As kwayland's goal is to turn an event-driven API into a property cache API we
store this data. This patch moves that storage to the Seat as properties of the
active drag, rather than a property of the data device that happened to
initialise it.

This both helps keep a lot of other logic together, but also allows us to expose
a public startDrag method that can be invoked from Kwin's internal surfaces or
xwayland.

Any properties in DataDevice now relate to data being dropped on the device.
2021-09-09 09:04:05 +00:00

55 lines
1.7 KiB
C++

/*
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include <QPointer>
#include "qwayland-server-wayland.h"
namespace KWaylandServer
{
class AbstractDataSource;
class DataDeviceInterface;
class DataOfferInterface;
class DataSourceInterface;
class DragAndDropIcon;
class SeatInterface;
class SurfaceInterface;
class DataDeviceInterfacePrivate : public QtWaylandServer::wl_data_device
{
public:
static DataDeviceInterfacePrivate *get(DataDeviceInterface *device);
DataDeviceInterfacePrivate(SeatInterface *seat, DataDeviceInterface *_q, wl_resource *resource);
DataOfferInterface *createDataOffer(AbstractDataSource *source);
SeatInterface *seat;
DataDeviceInterface *q;
QPointer<DataSourceInterface> selection;
QPointer<SurfaceInterface> proxyRemoteSurface;
struct Drag {
SurfaceInterface *surface = nullptr;
QMetaObject::Connection destroyConnection;
QMetaObject::Connection posConnection;
QMetaObject::Connection sourceActionConnection;
QMetaObject::Connection targetActionConnection;
quint32 serial = 0;
};
Drag drag;
protected:
void data_device_destroy_resource(Resource *resource) override;
void data_device_start_drag(Resource *resource, wl_resource *source, wl_resource *origin, wl_resource *icon, uint32_t serial) override;
void data_device_set_selection(Resource *resource, wl_resource *source, uint32_t serial) override;
void data_device_release(Resource *resource) override;
};
} // namespace KWaylandServer