2020-05-12 11:26:48 +00:00
|
|
|
/*
|
|
|
|
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 "clientconnection.h"
|
|
|
|
#include "datadevicemanager_interface.h"
|
|
|
|
|
|
|
|
#include <KWaylandServer/kwaylandserver_export.h>
|
|
|
|
|
|
|
|
struct wl_client;
|
|
|
|
|
2021-08-29 05:11:06 +00:00
|
|
|
namespace KWaylandServer
|
|
|
|
{
|
2020-05-12 11:26:48 +00:00
|
|
|
/**
|
|
|
|
* @brief The AbstractDataSource class abstracts the data that
|
|
|
|
* can be transferred to another client.
|
|
|
|
*
|
|
|
|
* It loosely maps to DataDeviceInterface
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Anything related to selections are pure virtual, content relating
|
|
|
|
// to drag and drop has a default implementation
|
|
|
|
|
2020-06-25 15:27:52 +00:00
|
|
|
class KWAYLANDSERVER_EXPORT AbstractDataSource : public QObject
|
2020-05-12 11:26:48 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-08-29 05:11:06 +00:00
|
|
|
virtual void accept(const QString &mimeType)
|
|
|
|
{
|
2020-05-12 11:26:48 +00:00
|
|
|
Q_UNUSED(mimeType);
|
|
|
|
};
|
|
|
|
virtual void requestData(const QString &mimeType, qint32 fd) = 0;
|
|
|
|
virtual void cancel() = 0;
|
|
|
|
|
|
|
|
virtual QStringList mimeTypes() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns The Drag and Drop actions supported by this DataSourceInterface.
|
2021-03-16 08:17:36 +00:00
|
|
|
*/
|
2021-08-29 05:11:06 +00:00
|
|
|
virtual DataDeviceManagerInterface::DnDActions supportedDragAndDropActions() const
|
|
|
|
{
|
2020-05-12 11:26:48 +00:00
|
|
|
return {};
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* The user performed the drop action during a drag and drop operation.
|
2021-03-16 08:17:36 +00:00
|
|
|
*/
|
2021-08-29 05:11:06 +00:00
|
|
|
virtual void dropPerformed(){};
|
2020-05-12 11:26:48 +00:00
|
|
|
/**
|
|
|
|
* The drop destination finished interoperating with this data source.
|
2021-03-16 08:17:36 +00:00
|
|
|
*/
|
2021-08-29 05:11:06 +00:00
|
|
|
virtual void dndFinished(){};
|
2020-05-12 11:26:48 +00:00
|
|
|
/**
|
|
|
|
* This event indicates the @p action selected by the compositor after matching the
|
|
|
|
* source/destination side actions. Only one action (or none) will be offered here.
|
2021-03-16 08:17:36 +00:00
|
|
|
*/
|
2021-08-29 05:11:06 +00:00
|
|
|
virtual void dndAction(DataDeviceManagerInterface::DnDAction action)
|
|
|
|
{
|
2020-05-12 11:26:48 +00:00
|
|
|
Q_UNUSED(action);
|
|
|
|
};
|
|
|
|
|
2021-08-29 05:11:06 +00:00
|
|
|
virtual wl_client *client() const
|
|
|
|
{
|
2020-06-25 15:27:52 +00:00
|
|
|
return nullptr;
|
|
|
|
};
|
2020-05-12 11:26:48 +00:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
2020-06-25 15:27:52 +00:00
|
|
|
void aboutToBeDestroyed();
|
|
|
|
|
2021-08-29 05:11:06 +00:00
|
|
|
void mimeTypeOffered(const QString &);
|
2020-05-12 11:26:48 +00:00
|
|
|
void supportedDragAndDropActionsChanged();
|
|
|
|
|
|
|
|
protected:
|
2020-06-25 15:27:52 +00:00
|
|
|
explicit AbstractDataSource(QObject *parent = nullptr);
|
2020-05-12 11:26:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|