KWaylandServer

pointer_interface.h
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3  SPDX-FileCopyrightText: 2020 Adrien Faveraux <[email protected]>
4  SPDX-FileCopyrightText: 2021 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 <KWaylandServer/kwaylandserver_export.h>
11 
12 #include <QObject>
13 
14 struct wl_resource;
15 
16 namespace KWaylandServer
17 {
18 
19 class CursorPrivate;
20 class Cursor;
21 class PointerInterfacePrivate;
22 class SeatInterface;
23 class SurfaceInterface;
24 
25 enum class PointerAxisSource;
26 enum class PointerButtonState : quint32;
27 
28 /**
29  * The PointerInterface class represents one or more input devices such as mice, which control
30  * the pointer location. It corresponds to the Wayland interface @c wl_pointer.
31  */
32 class KWAYLANDSERVER_EXPORT PointerInterface : public QObject
33 {
34  Q_OBJECT
35 
36 public:
37  ~PointerInterface() override;
38 
39  /**
40  * Returns the focused pointer surface. Note that the returned value may be different
41  * from SurfaceInterface::focusedSurfacePointerSurface() because this function returns
42  * the effective focused surface.
43  */
44  SurfaceInterface *focusedSurface() const;
45  /**
46  * Sets the effective focused pointer surface to @a surface. The @a position indicates
47  * where the pointer has entered the surface.
48  */
49  void setFocusedSurface(SurfaceInterface *surface, const QPointF &position, quint32 serial);
50 
51  Cursor *cursor() const;
52 
53  /**
54  * Returns the seat to which this pointer belongs to.
55  */
56  SeatInterface *seat() const;
57 
58  /**
59  * @returns The PointerInterface for the @p native resource.
60  */
61  static PointerInterface *get(wl_resource *native);
62 
63  void sendButton(quint32 button, PointerButtonState state, quint32 serial);
64  void sendAxis(Qt::Orientation orientation, qreal delta, qint32 discreteDelta, PointerAxisSource source);
65  void sendMotion(const QPointF &position);
66  void sendFrame();
67 
68 Q_SIGNALS:
69  /**
70  * This signal is emitted whenever the cursor surface changes. As long as there is no
71  * any focused surface, the cursor cannot be changed.
72  */
73  void cursorChanged();
74  /**
75  * This signal is emitted whenever the focused pointer surface changes.
76  */
77  void focusedSurfaceChanged();
78 
79 private:
80  explicit PointerInterface(SeatInterface *seat);
82 
83  friend class SeatInterface;
84  friend class PointerInterfacePrivate;
85 };
86 
87 /**
88  * @brief Class encapsulating a Cursor image.
89  */
90 class KWAYLANDSERVER_EXPORT Cursor : public QObject
91 {
92  Q_OBJECT
93 
94 public:
95  virtual ~Cursor();
96  /**
97  * The hotspot of the cursor image in surface-relative coordinates.
98  */
99  QPoint hotspot() const;
100  /**
101  * The entered serial when the Cursor got set.
102  */
103  quint32 enteredSerial() const;
104  /**
105  * The PointerInterface this Cursor belongs to.
106  */
107  PointerInterface *pointer() const;
108  /**
109  * The SurfaceInterface for the image content of the Cursor.
110  */
111  SurfaceInterface *surface() const;
112 
113 Q_SIGNALS:
114  void hotspotChanged();
115  void enteredSerialChanged();
116  void surfaceChanged();
117  void changed();
118 
119 private:
121  friend class PointerInterfacePrivate;
122  explicit Cursor(PointerInterface *parent);
123 };
124 
125 } // namespace KWaylandServer
Represents a Seat on the Wayland Display.
Class encapsulating a Cursor image.
The PointerInterface class represents one or more input devices such as mice, which control the point...
Resource representing a wl_surface.
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Aug 1 2021 23:08:14 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.