File indexing completed on 2024-05-19 05:32:49

0001 /*
0002     SPDX-FileCopyrightText: 2021 David Redondo <kde@david-redondo.de>
0003     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 */
0005 
0006 #pragma once
0007 
0008 #include "wayland/abstract_data_source.h"
0009 
0010 namespace KWin
0011 {
0012 namespace Xwl
0013 {
0014 
0015 /**
0016  * The XwlDataSource class represents a data source owned by the Xwayland data bridge. It's
0017  * used as a source in data transfers from X11 clients to Wayland clients.
0018  *
0019  * The XwlDataSource class is sealed as its destructor emits the aboutToBeDestroyed() signal.
0020  * If you decide to unseal it, ensure that the about to be destroyed signal is emitted properly!
0021  */
0022 class XwlDataSource final : public AbstractDataSource
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     ~XwlDataSource() override;
0028 
0029     void requestData(const QString &mimeType, qint32 fd) override;
0030     void cancel() override;
0031     QStringList mimeTypes() const override;
0032     void setMimeTypes(const QStringList &mimeTypes);
0033 
0034     void accept(const QString &mimeType) override;
0035     DataDeviceManagerInterface::DnDActions supportedDragAndDropActions() const override;
0036     void setSupportedDndActions(DataDeviceManagerInterface::DnDActions dndActions);
0037 
0038     DataDeviceManagerInterface::DnDAction selectedDndAction() const override;
0039     void dndAction(DataDeviceManagerInterface::DnDAction action) override;
0040 
0041     void dropPerformed() override
0042     {
0043         Q_EMIT dropped();
0044     }
0045     void dndFinished() override
0046     {
0047         Q_EMIT finished();
0048     }
0049     void dndCancelled() override
0050     {
0051         Q_EMIT cancelled();
0052     }
0053 
0054     bool isAccepted() const override;
0055 
0056 Q_SIGNALS:
0057     void dataRequested(const QString &mimeType, qint32 fd);
0058     void dropped();
0059     void finished();
0060     void cancelled();
0061 
0062 private:
0063     QStringList m_mimeTypes;
0064     DataDeviceManagerInterface::DnDActions m_supportedDndActions;
0065     DataDeviceManagerInterface::DnDAction m_dndAction = DataDeviceManagerInterface::DnDAction::None;
0066     bool m_accepted = false;
0067 };
0068 }
0069 }