KWayland

fakeinput_interface.h
1 /*
2  SPDX-FileCopyrightText: 2015 Martin Gräßlin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #ifndef KWAYLAND_SERVER_FAKEINPUT_INTERFACE_H
7 #define KWAYLAND_SERVER_FAKEINPUT_INTERFACE_H
8 
9 #include "global.h"
10 #include <KWayland/Server/kwaylandserver_export.h>
11 
12 struct wl_resource;
13 
14 namespace KWayland
15 {
16 namespace Server
17 {
18 class Display;
19 class FakeInputDevice;
20 
21 /**
22  * @brief Represents the Global for org_kde_kwin_fake_input interface.
23  *
24  * The fake input interface allows clients to send fake input events to the
25  * Wayland server. For the actual events it creates a FakeInputDevice. Whenever
26  * the FakeInputInterface creates a device the signal deviceCreated gets emitted.
27  *
28  * Accepting fake input events is a security risk. The server should make a
29  * dedicated decision about whether it wants to accept fake input events from a
30  * device. Because of that by default no events are forwarded to the server. The
31  * device needs to request authentication and the server must explicitly authenticate
32  * the device. The recommendation is that the server only accepts input for in some
33  * way trusted clients.
34  *
35  * @see FakeInputDevice
36  * @since 5.4
37  **/
38 class KWAYLANDSERVER_EXPORT FakeInputInterface : public Global
39 {
40  Q_OBJECT
41 public:
42  virtual ~FakeInputInterface();
43 
44 Q_SIGNALS:
45  /**
46  * Signal emitted whenever a client bound the fake input @p device.
47  * @param device The created FakeInputDevice
48  **/
49  void deviceCreated(KWayland::Server::FakeInputDevice *device);
50 
51 private:
52  explicit FakeInputInterface(Display *display, QObject *parent = nullptr);
53  friend class Display;
54  class Private;
55 };
56 
57 /**
58  * @brief Represents the Resource for a org_kde_kwin_fake_input interface.
59  *
60  * @see FakeInputInterface
61  * @since 5.4
62  **/
63 class KWAYLANDSERVER_EXPORT FakeInputDevice : public QObject
64 {
65  Q_OBJECT
66 public:
67  virtual ~FakeInputDevice();
68  /**
69  * @returns the native wl_resource.
70  **/
71  wl_resource *resource();
72 
73  /**
74  * Authenticate this device to send events. If @p authenticated is @c true events are
75  * accepted, for @c false events are no longer accepted.
76  *
77  * @param authenticated Whether the FakeInputDevice should be considered authenticated
78  **/
79  void setAuthentication(bool authenticated);
80  /**
81  * @returns whether the FakeInputDevice is authenticated and allowed to send events, default is @c false.
82  **/
83  bool isAuthenticated() const;
84 
85 Q_SIGNALS:
86  /**
87  * Request for authentication.
88  *
89  * The server might use the provided information to make a decision on whether the
90  * FakeInputDevice should get authenticated. It is recommended to not trust the data
91  * and to combine it with information from ClientConnection.
92  *
93  * @param application A textual description of the application
94  * @param reason A textual description of the reason why the application wants to send fake input events
95  **/
96  void authenticationRequested(const QString &application, const QString &reason);
97  /**
98  * Request a pointer motion by @p delta.
99  **/
100  void pointerMotionRequested(const QSizeF &delta);
101  /**
102  * Request an absolute pointer motion to @p pos.
103  *
104  * @since 5.54
105  **/
106  void pointerMotionAbsoluteRequested(const QPointF &pos);
107  /**
108  * Requests a pointer button pressed for @p button.
109  **/
110  void pointerButtonPressRequested(quint32 button);
111  /**
112  * Requests a pointer button release for @p button.
113  **/
114  void pointerButtonReleaseRequested(quint32 button);
115  /**
116  * Requests a pointer axis for the given @p orientation by @p delta.
117  **/
118  void pointerAxisRequested(Qt::Orientation orientation, qreal delta);
119  /**
120  * Requests a touch down at @p pos and identified by @p id.
121  *
122  * @since 5.23
123  **/
124  void touchDownRequested(quint32 id, const QPointF &pos);
125  /**
126  * Requests a touch motion by @p pos and identified by @p id.
127  *
128  * @since 5.23
129  **/
130  void touchMotionRequested(quint32 id, const QPointF &pos);
131  /**
132  * Requests a touch up identified by @p id.
133  *
134  * @since 5.23
135  **/
136  void touchUpRequested(quint32 id);
137  /**
138  * Requests a touch cancel event.
139  *
140  * @since 5.23
141  **/
142  void touchCancelRequested();
143  /**
144  * Requests a touch frame event.
145  *
146  * @since 5.23
147  **/
148  void touchFrameRequested();
149  /**
150  * Requests a keyboard key pressed for @p key.
151  *
152  * @since 5.63
153  **/
154  void keyboardKeyPressRequested(quint32 key);
155  /**
156  * Requests a keyboard key release for @p key.
157  *
158  * @since 5.63
159  **/
160  void keyboardKeyReleaseRequested(quint32 key);
161 
162 private:
163  friend class FakeInputInterface;
164  FakeInputDevice(wl_resource *resource, FakeInputInterface *parent);
165  class Private;
167 };
168 
169 }
170 }
171 
172 Q_DECLARE_METATYPE(KWayland::Server::FakeInputDevice *)
173 
174 #endif
Represents the Resource for a org_kde_kwin_fake_input interface.
Class holding the Wayland server display loop.
Definition: display.h:86
Base class for all Globals.
Definition: global.h:46
Orientation
Represents the Global for org_kde_kwin_fake_input interface.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Sep 23 2021 22:51:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.