2020-03-15 15:19:28 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
2020-06-25 15:27:52 +00:00
|
|
|
SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
|
2020-10-29 08:29:30 +00:00
|
|
|
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2020-03-15 15:19:28 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2021-03-10 16:08:30 +00:00
|
|
|
#pragma once
|
2014-11-06 09:02:49 +00:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
#include <KWaylandServer/kwaylandserver_export.h>
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2021-04-05 08:18:08 +00:00
|
|
|
struct wl_client;
|
|
|
|
struct wl_resource;
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
namespace KWaylandServer
|
2014-11-06 09:02:49 +00:00
|
|
|
{
|
|
|
|
class DataDeviceManagerInterface;
|
2016-03-01 06:49:04 +00:00
|
|
|
class DataOfferInterface;
|
2014-11-06 09:02:49 +00:00
|
|
|
class DataSourceInterface;
|
2020-05-12 11:26:48 +00:00
|
|
|
class AbstractDataSource;
|
2014-11-06 09:02:49 +00:00
|
|
|
class SeatInterface;
|
|
|
|
class SurfaceInterface;
|
2020-06-25 15:27:52 +00:00
|
|
|
class DataDeviceInterfacePrivate;
|
2020-10-29 08:29:30 +00:00
|
|
|
class DragAndDropIconPrivate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The DragAndDropIcon class represents a drag-and-drop icon.
|
|
|
|
*
|
|
|
|
* Note that the lifetime of the drag-and-drop icon is bound to the lifetime of the underlying
|
|
|
|
* icon surface.
|
|
|
|
*/
|
|
|
|
class KWAYLANDSERVER_EXPORT DragAndDropIcon : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
~DragAndDropIcon() override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the position of the icon relative to the cursor's hotspot.
|
|
|
|
*/
|
|
|
|
QPoint position() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the underlying icon surface. This function always returns a valid surface.
|
|
|
|
*/
|
|
|
|
SurfaceInterface *surface() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
explicit DragAndDropIcon(SurfaceInterface *surface, QObject *parent = nullptr);
|
|
|
|
friend class DataDeviceInterfacePrivate;
|
|
|
|
QScopedPointer<DragAndDropIconPrivate> d;
|
|
|
|
};
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2015-09-10 11:36:42 +00:00
|
|
|
/**
|
2019-09-15 18:59:45 +00:00
|
|
|
* @brief DataDeviceInterface allows clients to share data by copy-and-paste and drag-and-drop.
|
|
|
|
*
|
|
|
|
* The data device is per seat.
|
|
|
|
* Copy-and-paste use the selection functions.
|
|
|
|
*
|
|
|
|
* Represents the Resource for the wl_data_device interface.
|
2015-09-10 11:36:42 +00:00
|
|
|
*
|
|
|
|
* @see SeatInterface
|
|
|
|
* @see DataSourceInterface
|
2021-03-16 08:17:36 +00:00
|
|
|
*/
|
2020-06-25 15:27:52 +00:00
|
|
|
class KWAYLANDSERVER_EXPORT DataDeviceInterface : public QObject
|
2014-11-06 09:02:49 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
virtual ~DataDeviceInterface();
|
|
|
|
|
|
|
|
SeatInterface *seat() const;
|
|
|
|
DataSourceInterface *dragSource() const;
|
|
|
|
SurfaceInterface *origin() const;
|
2020-10-29 08:29:30 +00:00
|
|
|
/**
|
|
|
|
* Returns the additional icon attached to the cursor during a drag-and-drop operation.
|
|
|
|
* This function returns @c null if no drag-and-drop icon has been attached.
|
|
|
|
*/
|
|
|
|
DragAndDropIcon *icon() const;
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2016-03-01 06:49:04 +00:00
|
|
|
/**
|
|
|
|
* @returns the serial of the implicit grab which started the drag
|
2021-03-16 08:17:36 +00:00
|
|
|
*/
|
2016-03-01 06:49:04 +00:00
|
|
|
quint32 dragImplicitGrabSerial() const;
|
|
|
|
|
2014-11-06 09:02:49 +00:00
|
|
|
DataSourceInterface *selection() const;
|
|
|
|
|
2020-05-12 11:26:48 +00:00
|
|
|
void sendSelection(KWaylandServer::AbstractDataSource *other);
|
2014-11-27 12:38:24 +00:00
|
|
|
void sendClearSelection();
|
2016-03-01 06:49:04 +00:00
|
|
|
/**
|
|
|
|
* The event is sent when a drag-and-drop operation is ended because the implicit grab is removed.
|
2021-03-16 08:17:36 +00:00
|
|
|
*/
|
2016-03-01 06:49:04 +00:00
|
|
|
void drop();
|
|
|
|
/**
|
|
|
|
* Updates the SurfaceInterface to which drag motion events are sent.
|
|
|
|
*
|
|
|
|
* If a SurfaceInterface was registered in this DataDeviceInterface for drag motion events, it
|
|
|
|
* will be sent a leave event.
|
|
|
|
*
|
|
|
|
* If @p surface is not null it will be sent a drag enter event.
|
|
|
|
*
|
|
|
|
* @param surface The SurfaceInterface which gets motion events
|
|
|
|
* @param serial The serial to be used for enter/leave
|
2021-03-16 08:17:36 +00:00
|
|
|
*/
|
2016-03-01 06:49:04 +00:00
|
|
|
void updateDragTarget(SurfaceInterface *surface, quint32 serial);
|
2019-02-06 08:26:43 +00:00
|
|
|
/**
|
|
|
|
* Mark this DataDeviceInterface as being a proxy device for @p remote.
|
2021-03-16 08:17:36 +00:00
|
|
|
*/
|
2019-02-06 08:26:43 +00:00
|
|
|
void updateProxy(SurfaceInterface *remote);
|
2014-11-06 15:56:50 +00:00
|
|
|
|
2020-06-25 15:27:52 +00:00
|
|
|
wl_client *client();
|
|
|
|
|
2014-11-06 09:02:49 +00:00
|
|
|
Q_SIGNALS:
|
2020-11-11 13:59:49 +00:00
|
|
|
void aboutToBeDestroyed();
|
2014-11-06 09:02:49 +00:00
|
|
|
void dragStarted();
|
2021-08-29 05:11:06 +00:00
|
|
|
void selectionChanged(KWaylandServer::DataSourceInterface *);
|
2014-11-06 09:02:49 +00:00
|
|
|
void selectionCleared();
|
|
|
|
|
|
|
|
private:
|
2020-06-25 15:27:52 +00:00
|
|
|
friend class DataDeviceManagerInterfacePrivate;
|
|
|
|
explicit DataDeviceInterface(SeatInterface *seat, wl_resource *resource);
|
|
|
|
QScopedPointer<DataDeviceInterfacePrivate> d;
|
2020-10-29 08:29:30 +00:00
|
|
|
friend class DataDeviceInterfacePrivate;
|
2014-11-06 09:02:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-08-29 05:11:06 +00:00
|
|
|
Q_DECLARE_METATYPE(KWaylandServer::DataDeviceInterface *)
|