2021-08-19 09:34:29 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2021 David Redondo <kde@david-redondo.de>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <KWaylandServer/abstract_data_source.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
namespace Xwl
|
|
|
|
{
|
2022-01-25 08:18:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The XwlDataSource class represents a data source owned by the Xwayland data bridge. It's
|
|
|
|
* used as a source in data transfers from X11 clients to Wayland clients.
|
|
|
|
*
|
|
|
|
* The XwlDataSource class is sealed as its destructor emits the aboutToBeDestroyed() signal.
|
|
|
|
* If you decide to unseal it, ensure that the about to be destroyed signal is emitted properly!
|
|
|
|
*/
|
|
|
|
class XwlDataSource final : public KWaylandServer::AbstractDataSource
|
2021-08-19 09:34:29 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2022-01-25 08:18:29 +00:00
|
|
|
|
2021-08-19 09:34:29 +00:00
|
|
|
public:
|
2022-01-25 08:18:29 +00:00
|
|
|
~XwlDataSource() override;
|
|
|
|
|
2021-08-19 09:34:29 +00:00
|
|
|
void requestData(const QString &mimeType, qint32 fd) override;
|
|
|
|
void cancel() override;
|
|
|
|
QStringList mimeTypes() const override;
|
|
|
|
void setMimeTypes(const QStringList &mimeTypes);
|
2021-09-03 11:48:09 +00:00
|
|
|
|
|
|
|
void accept(const QString &mimeType) override;
|
|
|
|
KWaylandServer::DataDeviceManagerInterface::DnDActions supportedDragAndDropActions() const override;
|
|
|
|
void setSupportedDndActions(KWaylandServer::DataDeviceManagerInterface::DnDActions dndActions);
|
|
|
|
|
|
|
|
void dndAction(KWaylandServer::DataDeviceManagerInterface::DnDAction action) override;
|
|
|
|
|
|
|
|
KWaylandServer::DataDeviceManagerInterface::DnDAction selectedDragAndDropAction() {
|
|
|
|
return m_dndAction;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dropPerformed() override {
|
|
|
|
Q_EMIT dropped();
|
|
|
|
}
|
|
|
|
void dndFinished() override {
|
|
|
|
Q_EMIT finished();
|
|
|
|
}
|
2022-02-03 13:26:05 +00:00
|
|
|
void dndCancelled() override {
|
|
|
|
Q_EMIT cancelled();
|
|
|
|
}
|
|
|
|
|
2021-09-03 11:48:09 +00:00
|
|
|
bool isAccepted() const override;
|
|
|
|
|
2021-08-19 09:34:29 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void dataRequested(const QString &mimeType, qint32 fd);
|
2021-09-03 11:48:09 +00:00
|
|
|
void dropped();
|
|
|
|
void finished();
|
2022-02-03 13:26:05 +00:00
|
|
|
void cancelled();
|
2021-08-19 09:34:29 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QStringList m_mimeTypes;
|
2021-09-03 11:48:09 +00:00
|
|
|
KWaylandServer::DataDeviceManagerInterface::DnDActions m_supportedDndActions;
|
|
|
|
KWaylandServer::DataDeviceManagerInterface::DnDAction m_dndAction = KWaylandServer::DataDeviceManagerInterface::DnDAction::None;
|
|
|
|
bool m_accepted = false;
|
2021-08-19 09:34:29 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|