KWaylandServer

datadevice_interface.h
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3  SPDX-FileCopyrightText: 2020 David Edmundson <[email protected]>
4  SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8 #pragma once
9 
10 #include <QObject>
11 
12 #include <KWaylandServer/kwaylandserver_export.h>
13 
14 #include "abstract_drop_handler.h"
15 
16 struct wl_client;
17 struct wl_resource;
18 
19 namespace KWaylandServer
20 {
21 class DataDeviceManagerInterface;
22 class DataOfferInterface;
23 class DataSourceInterface;
24 class AbstractDataSource;
25 class SeatInterface;
26 class SurfaceInterface;
27 class DataDeviceInterfacePrivate;
28 class DragAndDropIconPrivate;
29 
30 /**
31  * The DragAndDropIcon class represents a drag-and-drop icon.
32  *
33  * Note that the lifetime of the drag-and-drop icon is bound to the lifetime of the underlying
34  * icon surface.
35  */
36 class KWAYLANDSERVER_EXPORT DragAndDropIcon : public QObject
37 {
38  Q_OBJECT
39 
40 public:
41  ~DragAndDropIcon() override;
42 
43  /**
44  * Returns the position of the icon relative to the cursor's hotspot.
45  */
46  QPoint position() const;
47 
48  /**
49  * Returns the underlying icon surface. This function always returns a valid surface.
50  */
51  SurfaceInterface *surface() const;
52 
53 private:
54  explicit DragAndDropIcon(SurfaceInterface *surface);
55  friend class DataDeviceInterfacePrivate;
57 };
58 
59 /**
60  * @brief DataDeviceInterface allows clients to share data by copy-and-paste and drag-and-drop.
61  *
62  * The data device is per seat.
63  * Copy-and-paste use the selection functions.
64  *
65  * Represents the Resource for the wl_data_device interface.
66  *
67  * @see SeatInterface
68  * @see DataSourceInterface
69  */
70 class KWAYLANDSERVER_EXPORT DataDeviceInterface : public AbstractDropHandler
71 {
72  Q_OBJECT
73 public:
74  virtual ~DataDeviceInterface();
75 
76  SeatInterface *seat() const;
77 
78  DataSourceInterface *selection() const;
79 
80  void sendSelection(KWaylandServer::AbstractDataSource *other);
81  void sendClearSelection();
82  /**
83  * The event is sent when a drag-and-drop operation is ended because the implicit grab is removed.
84  */
85  void drop() override;
86  /**
87  * Updates the SurfaceInterface to which drag motion events are sent.
88  *
89  * If a SurfaceInterface was registered in this DataDeviceInterface for drag motion events, it
90  * will be sent a leave event.
91  *
92  * If @p surface is not null it will be sent a drag enter event.
93  *
94  * @param surface The SurfaceInterface which gets motion events
95  * @param serial The serial to be used for enter/leave
96  */
97  void updateDragTarget(SurfaceInterface *surface, quint32 serial) override;
98  void updateProxy(SurfaceInterface *remote);
99 
100  wl_client *client();
101 
102 Q_SIGNALS:
103  void aboutToBeDestroyed();
104  void dragStarted(AbstractDataSource *source, SurfaceInterface *originSurface, quint32 serial, DragAndDropIcon *dragIcon);
105  void selectionChanged(KWaylandServer::DataSourceInterface *);
106  void selectionCleared();
107 
108 private:
109  friend class DataDeviceManagerInterfacePrivate;
110  explicit DataDeviceInterface(SeatInterface *seat, wl_resource *resource);
112  friend class DataDeviceInterfacePrivate;
113 };
114 
115 }
116 
117 Q_DECLARE_METATYPE(KWaylandServer::DataDeviceInterface *)
The AbstractDataSource class abstracts the data that can be transferred to another client...
Represents a Seat on the Wayland Display.
DataDeviceInterface allows clients to share data by copy-and-paste and drag-and-drop.
Represents the Resource for the wl_data_source interface.
Resource representing a wl_surface.
The DragAndDropIcon class represents a drag-and-drop icon.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:08:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.