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

KDE's Doxygen guidelines are available online.