KWaylandServer

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 #pragma once
7 
8 #include <QObject>
9 #include <QPointF>
10 #include <QSizeF>
11 
12 #include <KWaylandServer/kwaylandserver_export.h>
13 
14 struct wl_resource;
15 
16 namespace KWaylandServer
17 {
18 class Display;
19 class FakeInputDevice;
20 class FakeInputDevicePrivate;
21 class FakeInputInterfacePrivate;
22 
23 /**
24  * @brief Represents the Global for org_kde_kwin_fake_input interface.
25  *
26  * The fake input interface allows clients to send fake input events to the
27  * Wayland server. For the actual events it creates a FakeInputDevice. Whenever
28  * the FakeInputInterface creates a device the signal deviceCreated gets emitted.
29  *
30  * Accepting fake input events is a security risk. The server should make a
31  * dedicated decision about whether it wants to accept fake input events from a
32  * device. Because of that by default no events are forwarded to the server. The
33  * device needs to request authentication and the server must explicitly authenticate
34  * the device. The recommendation is that the server only accepts input for in some
35  * way trusted clients.
36  *
37  * @see FakeInputDevice
38  */
39 class KWAYLANDSERVER_EXPORT FakeInputInterface : public QObject
40 {
41  Q_OBJECT
42 
43 public:
44  explicit FakeInputInterface(Display *display, QObject *parent = nullptr);
45  ~FakeInputInterface() override;
46 
47 Q_SIGNALS:
48  /**
49  * Signal emitted whenever a client bound the fake input @p device.
50  * @param device The created FakeInputDevice
51  */
52  void deviceCreated(KWaylandServer::FakeInputDevice *device);
53 
54 private:
56 };
57 
58 /**
59  * @brief Represents the Resource for a org_kde_kwin_fake_input interface.
60  *
61  * @see FakeInputInterface
62  */
63 class KWAYLANDSERVER_EXPORT FakeInputDevice : public QObject
64 {
65  Q_OBJECT
66 public:
67  ~FakeInputDevice() override;
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  void pointerMotionAbsoluteRequested(const QPointF &pos);
105  /**
106  * Requests a pointer button pressed for @p button.
107  */
108  void pointerButtonPressRequested(quint32 button);
109  /**
110  * Requests a pointer button release for @p button.
111  */
112  void pointerButtonReleaseRequested(quint32 button);
113  /**
114  * Requests a pointer axis for the given @p orientation by @p delta.
115  */
116  void pointerAxisRequested(Qt::Orientation orientation, qreal delta);
117  /**
118  * Requests a touch down at @p pos and identified by @p id.
119  */
120  void touchDownRequested(quint32 id, const QPointF &pos);
121  /**
122  * Requests a touch motion by @p pos and identified by @p id.
123  */
124  void touchMotionRequested(quint32 id, const QPointF &pos);
125  /**
126  * Requests a touch up identified by @p id.
127  */
128  void touchUpRequested(quint32 id);
129  /**
130  * Requests a touch cancel event.
131  */
132  void touchCancelRequested();
133  /**
134  * Requests a touch frame event.
135  */
136  void touchFrameRequested();
137  /**
138  * Requests a keyboard key pressed for @p key.
139  */
140  void keyboardKeyPressRequested(quint32 key);
141  /**
142  * Requests a keyboard key release for @p key.
143  */
144  void keyboardKeyReleaseRequested(quint32 key);
145 
146 private:
147  friend class FakeInputInterfacePrivate;
148  FakeInputDevice(FakeInputInterface *parent, wl_resource *resource);
150 };
151 
152 }
153 
154 Q_DECLARE_METATYPE(KWaylandServer::FakeInputDevice *)
Class holding the Wayland server display loop.
Definition: display.h:47
Represents the Global for org_kde_kwin_fake_input interface.
Represents the Resource for a org_kde_kwin_fake_input interface.
Orientation
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.