KWaylandServer

textinput_v3_interface.h
1 /*
2  SPDX-FileCopyrightText: 2018 Roman Glig <[email protected]>
3  SPDX-FileCopyrightText: 2020 Bhushan Shah <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7 #pragma once
8 
9 #include <QObject>
10 
11 #include "textinput.h"
12 #include <KWaylandServer/kwaylandserver_export.h>
13 
14 struct wl_resource;
15 namespace KWaylandServer
16 {
17 class Display;
18 class SeatInterface;
19 class SurfaceInterface;
20 class TextInputV3Interface;
21 class TextInputV3InterfacePrivate;
22 class TextInputManagerV3InterfacePrivate;
23 
24 /**
25  * @brief Represent the Global for the interface.
26  *
27  * The class can represent different interfaces. Which concrete interface is represented
28  * can be determined through {@link interfaceVersion}.
29  *
30  * To create a TextInputManagerV3Interface use {@link Display::createTextInputManager}
31  */
32 class KWAYLANDSERVER_EXPORT TextInputManagerV3Interface : public QObject
33 {
34  Q_OBJECT
35 public:
36  explicit TextInputManagerV3Interface(Display *display, QObject *parent = nullptr);
37  ~TextInputManagerV3Interface() override;
38 
39 private:
41 };
42 
43 /**
44  * @brief Represents a generic Resource for a text input object.
45  * *
46  * A TextInputV3Interface gets created by the {@link TextInputManagerV3Interface}. The individual
47  * instances are not exposed directly. The SeatInterface provides access to the currently active
48  * TextInputV3Interface. This is evaluated automatically based on which SurfaceInterface has
49  * keyboard focus.
50  *
51  * @see TextInputManagerV3Interface
52  * @see SeatInterface
53  */
54 class KWAYLANDSERVER_EXPORT TextInputV3Interface : public QObject
55 {
56  Q_OBJECT
57 public:
58  ~TextInputV3Interface() override;
59 
60  /**
61  * @see cursorRectangleChanged
62  */
63  QRect cursorRectangle() const;
64 
65  /**
66  * @see contentTypeChanged
67  */
68  TextInputContentPurpose contentPurpose() const;
69 
70  /**
71  *@see contentTypeChanged
72  */
73  TextInputContentHints contentHints() const;
74 
75  /**
76  * @returns The plain surrounding text around the input position.
77  * @see surroundingTextChanged
78  * @see surroundingTextCursorPosition
79  * @see surroundingTextSelectionAnchor
80  */
81  QString surroundingText() const;
82  /**
83  * @returns The byte offset of current cursor position within the {@link surroundingText}
84  * @see surroundingText
85  * @see surroundingTextChanged
86  */
87  qint32 surroundingTextCursorPosition() const;
88  /**
89  * The byte offset of the selection anchor within the {@link surroundingText}.
90  *
91  * If there is no selected text this is the same as cursor.
92  * @return The byte offset of the selection anchor
93  * @see surroundingText
94  * @see surroundingTextChanged
95  */
96  qint32 surroundingTextSelectionAnchor() const;
97 
98  /**
99  * @return The surface the TextInputV3Interface is enabled on
100  * @see isEnabled
101  * @see enabledChanged
102  */
103  QPointer<SurfaceInterface> surface() const;
104 
105  /**
106  * @return Whether the TextInputV3Interface is currently enabled for a SurfaceInterface.
107  * @see surface
108  * @see enabledChanged
109  */
110  bool isEnabled() const;
111 
112  /**
113  * Notify when the text around the current cursor position should be deleted.
114  *
115  * The Client processes this event together with the commit string
116  *
117  * @param beforeLength length of text before current cursor position.
118  * @param afterLength length of text after current cursor position.
119  * @see commit
120  */
121  void deleteSurroundingText(quint32 beforeLength, quint32 afterLength);
122 
123  /**
124  * Send preEditString to the client
125  *
126  * @param text pre-edit string
127  * @param cursorBegin
128  * @param cursorEnd
129  */
130  void sendPreEditString(const QString &text, quint32 cursorBegin, quint32 cursorEnd);
131 
132  /**
133  * Notify when @p text should be inserted into the editor widget.
134  * The text to commit could be either just a single character after a key press or the
135  * result of some composing ({@link preEdit}). It could be also an empty text
136  * when some text should be removed (see {@link deleteSurroundingText}) or when
137  * the input cursor should be moved (see {@link cursorPosition}).
138  *
139  * Any previously set composing text should be removed.
140  * @param text The utf8-encoded text to be inserted into the editor widget
141  * @see preEdit
142  * @see deleteSurroundingText
143  */
144  void commitString(const QString &text);
145 
146  /**
147  * Notify when changes and state requested by sendPreEditString, commitString and deleteSurroundingText
148  * should be applied.
149  */
150  void done();
151 
152 Q_SIGNALS:
153 
154  /**
155  * @see cursorRectangle
156  */
157  void cursorRectangleChanged(const QRect &rect);
158  /**
159  * Emitted when the {@link contentPurpose} and/or {@link contentHints} changes.
160  * @see contentPurpose
161  * @see contentHints
162  */
163  void contentTypeChanged();
164 
165  /**
166  * Emitted when the {@link surroundingText}, {@link surroundingTextCursorPosition}
167  * and/or {@link surroundingTextSelectionAnchor} changed.
168  * @see surroundingText
169  * @see surroundingTextCursorPosition
170  * @see surroundingTextSelectionAnchor
171  */
172  void surroundingTextChanged();
173 
174  /**
175  * Emitted whenever this TextInputV3Interface gets enabled or disabled for a SurfaceInterface.
176  * @see isEnabled
177  * @see surface
178  */
179  void enabledChanged();
180 
181  /**
182  * Emitted when state should be committed
183  */
184  void stateCommitted(quint32 serial);
185 
186 private:
187  friend class TextInputManagerV3InterfacePrivate;
188  friend class SeatInterface;
189  friend class SeatInterfacePrivate;
190  friend class TextInputV3InterfacePrivate;
191  explicit TextInputV3Interface(SeatInterface *seat);
192 
194 };
195 
196 }
197 
198 Q_DECLARE_METATYPE(KWaylandServer::TextInputV3Interface *)
Represents a Seat on the Wayland Display.
Class holding the Wayland server display loop.
Definition: display.h:47
Represent the Global for the interface.
Represents a generic Resource for a text input object.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 23:08:44 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.