File indexing completed on 2024-05-12 05:32:19
0001 /* 0002 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org> 0004 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 #pragma once 0009 0010 #include "kwin_export.h" 0011 0012 #include <QObject> 0013 #include <memory> 0014 0015 #include "abstract_drop_handler.h" 0016 0017 struct wl_client; 0018 struct wl_resource; 0019 0020 namespace KWin 0021 { 0022 class DataDeviceManagerInterface; 0023 class DataOfferInterface; 0024 class DataSourceInterface; 0025 class AbstractDataSource; 0026 class SeatInterface; 0027 class SurfaceInterface; 0028 class SurfaceRole; 0029 class DataDeviceInterfacePrivate; 0030 class DragAndDropIconPrivate; 0031 0032 /** 0033 * The DragAndDropIcon class represents a drag-and-drop icon. 0034 * 0035 * Note that the lifetime of the drag-and-drop icon is bound to the lifetime of the underlying 0036 * icon surface. 0037 */ 0038 class KWIN_EXPORT DragAndDropIcon : public QObject 0039 { 0040 Q_OBJECT 0041 0042 public: 0043 ~DragAndDropIcon() override; 0044 0045 static SurfaceRole *role(); 0046 0047 /** 0048 * Returns the position of the icon relative to the cursor's hotspot. 0049 */ 0050 QPoint position() const; 0051 0052 /** 0053 * Returns the underlying icon surface. This function always returns a valid surface. 0054 */ 0055 SurfaceInterface *surface() const; 0056 0057 Q_SIGNALS: 0058 void changed(); 0059 0060 private: 0061 void commit(); 0062 0063 explicit DragAndDropIcon(SurfaceInterface *surface); 0064 friend class DataDeviceInterfacePrivate; 0065 std::unique_ptr<DragAndDropIconPrivate> d; 0066 }; 0067 0068 /** 0069 * @brief DataDeviceInterface allows clients to share data by copy-and-paste and drag-and-drop. 0070 * 0071 * The data device is per seat. 0072 * Copy-and-paste use the selection functions. 0073 * 0074 * Represents the Resource for the wl_data_device interface. 0075 * 0076 * @see SeatInterface 0077 * @see DataSourceInterface 0078 */ 0079 class KWIN_EXPORT DataDeviceInterface : public AbstractDropHandler 0080 { 0081 Q_OBJECT 0082 public: 0083 virtual ~DataDeviceInterface(); 0084 0085 SeatInterface *seat() const; 0086 0087 DataSourceInterface *selection() const; 0088 0089 void sendSelection(KWin::AbstractDataSource *other); 0090 /** 0091 * The event is sent when a drag-and-drop operation is ended because the implicit grab is removed. 0092 */ 0093 void drop() override; 0094 /** 0095 * Updates the SurfaceInterface to which drag motion events are sent. 0096 * 0097 * If a SurfaceInterface was registered in this DataDeviceInterface for drag motion events, it 0098 * will be sent a leave event. 0099 * 0100 * If @p surface is not null it will be sent a drag enter event. 0101 * 0102 * @param surface The SurfaceInterface which gets motion events 0103 * @param serial The serial to be used for enter/leave 0104 */ 0105 void updateDragTarget(SurfaceInterface *surface, quint32 serial) override; 0106 0107 wl_client *client(); 0108 0109 Q_SIGNALS: 0110 void aboutToBeDestroyed(); 0111 void dragStarted(AbstractDataSource *source, SurfaceInterface *originSurface, quint32 serial, DragAndDropIcon *dragIcon); 0112 void selectionChanged(KWin::DataSourceInterface *); 0113 0114 private: 0115 friend class DataDeviceManagerInterfacePrivate; 0116 explicit DataDeviceInterface(SeatInterface *seat, wl_resource *resource); 0117 std::unique_ptr<DataDeviceInterfacePrivate> d; 0118 friend class DataDeviceInterfacePrivate; 0119 }; 0120 0121 } 0122 0123 Q_DECLARE_METATYPE(KWin::DataDeviceInterface *)