File indexing completed on 2024-05-19 05:32:33
0001 /* 0002 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 #pragma once 0008 0009 #include "kwin_export.h" 0010 0011 #include <QObject> 0012 0013 #include "datadevicemanager.h" 0014 0015 #include <optional> 0016 0017 namespace KWin 0018 { 0019 class DataDeviceInterface; 0020 class AbstractDataSource; 0021 class DataOfferInterfacePrivate; 0022 0023 /** 0024 * @brief Represents the Resource for the wl_data_offer interface. 0025 * 0026 */ 0027 class KWIN_EXPORT DataOfferInterface : public QObject 0028 { 0029 Q_OBJECT 0030 public: 0031 virtual ~DataOfferInterface(); 0032 0033 void sendAllOffers(); 0034 void sendSourceActions(); 0035 wl_resource *resource() const; 0036 0037 /** 0038 * @returns The Drag and Drop actions supported by this DataOfferInterface. 0039 */ 0040 std::optional<DataDeviceManagerInterface::DnDActions> supportedDragAndDropActions() const; 0041 0042 /** 0043 * @returns The preferred Drag and Drop action of this DataOfferInterface. 0044 */ 0045 std::optional<DataDeviceManagerInterface::DnDAction> preferredDragAndDropAction() const; 0046 0047 /** 0048 * This event indicates the @p action selected by the compositor after matching the 0049 * source/destination side actions. Only one action (or none) will be offered here. 0050 */ 0051 void dndAction(DataDeviceManagerInterface::DnDAction action); 0052 0053 Q_SIGNALS: 0054 /** 0055 * Emitted whenever the supported or preferred Drag and Drop actions changed. 0056 */ 0057 void dragAndDropActionsChanged(); 0058 0059 private: 0060 friend class DataDeviceInterfacePrivate; 0061 explicit DataOfferInterface(AbstractDataSource *source, wl_resource *resource); 0062 0063 std::unique_ptr<DataOfferInterfacePrivate> d; 0064 }; 0065 0066 } 0067 0068 Q_DECLARE_METATYPE(KWin::DataOfferInterface *)