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
|
|
|
|
|
2022-04-22 09:27:33 +00:00
|
|
|
#include "wayland/abstract_data_source.h"
|
2021-08-19 09:34:29 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
KWaylandServer::DataDeviceManagerInterface::DnDAction selectedDragAndDropAction()
|
|
|
|
{
|
2021-09-03 11:48:09 +00:00
|
|
|
return m_dndAction;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void dropPerformed() override
|
|
|
|
{
|
2021-09-03 11:48:09 +00:00
|
|
|
Q_EMIT dropped();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
void dndFinished() override
|
|
|
|
{
|
2021-09-03 11:48:09 +00:00
|
|
|
Q_EMIT finished();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
void dndCancelled() override
|
|
|
|
{
|
2022-02-03 13:26:05 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|