Changeset View
Changeset View
Standalone View
Standalone View
src/client/textinput_p.h
1 | /**************************************************************************** | 1 | /**************************************************************************** | ||
---|---|---|---|---|---|
2 | Copyright 2016 Martin Gräßlin <mgraesslin@kde.org> | 2 | Copyright 2016 Martin Gräßlin <mgraesslin@kde.org> | ||
3 | Copyright 2018 Roman Gilg <subdiff@gmail.com> | ||||
3 | 4 | | |||
4 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either | ||
7 | version 2.1 of the License, or (at your option) version 3, or any | 8 | version 2.1 of the License, or (at your option) version 3, or any | ||
8 | later version accepted by the membership of KDE e.V. (or its | 9 | later version accepted by the membership of KDE e.V. (or its | ||
9 | successor approved by the membership of KDE e.V.), which shall | 10 | successor approved by the membership of KDE e.V.), which shall | ||
10 | act as a proxy defined in Section 6 of version 3 of the license. | 11 | act as a proxy defined in Section 6 of version 3 of the license. | ||
Show All 10 Lines | |||||
21 | #define KWAYLAND_CLIENT_TEXTINPUT_P_H | 22 | #define KWAYLAND_CLIENT_TEXTINPUT_P_H | ||
22 | #include "textinput.h" | 23 | #include "textinput.h" | ||
23 | 24 | | |||
24 | #include <QObject> | 25 | #include <QObject> | ||
25 | 26 | | |||
26 | struct wl_text_input; | 27 | struct wl_text_input; | ||
27 | struct wl_text_input_manager; | 28 | struct wl_text_input_manager; | ||
28 | struct zwp_text_input_v2; | 29 | struct zwp_text_input_v2; | ||
30 | struct zwp_text_input_v3; | ||||
29 | 31 | | |||
30 | namespace KWayland | 32 | namespace KWayland | ||
31 | { | 33 | { | ||
32 | namespace Client | 34 | namespace Client | ||
33 | { | 35 | { | ||
34 | 36 | | |||
35 | class EventQueue; | 37 | class EventQueue; | ||
36 | class TextInputUnstableV0; | 38 | class TextInputUnstableV0; | ||
Show All 31 Lines | 63 | public: | |||
68 | explicit TextInputManagerUnstableV2(QObject *parent = nullptr); | 70 | explicit TextInputManagerUnstableV2(QObject *parent = nullptr); | ||
69 | virtual ~TextInputManagerUnstableV2(); | 71 | virtual ~TextInputManagerUnstableV2(); | ||
70 | 72 | | |||
71 | private: | 73 | private: | ||
72 | class Private; | 74 | class Private; | ||
73 | QScopedPointer<Private> d; | 75 | QScopedPointer<Private> d; | ||
74 | }; | 76 | }; | ||
75 | 77 | | |||
78 | class TextInputManagerUnstableV3 : public TextInputManager | ||||
79 | { | ||||
80 | Q_OBJECT | ||||
81 | public: | ||||
82 | /** | ||||
83 | * Creates a new TextInputManagerUnstableV0. | ||||
zzag: V3? | |||||
84 | * Note: after constructing the TextInputManagerUnstableV0 it is not yet valid and one needs | ||||
85 | * to call setup. In order to get a ready to use TextInputManagerUnstableV0 prefer using | ||||
86 | * Registry::createTextInputManagerUnstableV0. | ||||
87 | **/ | ||||
88 | explicit TextInputManagerUnstableV3(QObject *parent = nullptr); | ||||
89 | virtual ~TextInputManagerUnstableV3(); | ||||
90 | | ||||
91 | private: | ||||
92 | class Private; | ||||
93 | QScopedPointer<Private> d; | ||||
94 | }; | ||||
95 | | ||||
76 | class Q_DECL_HIDDEN TextInputManager::Private | 96 | class Q_DECL_HIDDEN TextInputManager::Private | ||
77 | { | 97 | { | ||
78 | public: | 98 | public: | ||
79 | Private() = default; | 99 | Private() = default; | ||
80 | virtual ~Private() = default; | 100 | virtual ~Private() = default; | ||
81 | 101 | | |||
82 | virtual void release() = 0; | 102 | virtual void release() = 0; | ||
83 | virtual void destroy() = 0; | 103 | virtual void destroy() = 0; | ||
84 | virtual bool isValid() = 0; | 104 | virtual bool isValid() = 0; | ||
85 | virtual void setupV0(wl_text_input_manager *textinputmanagerunstablev0) { | 105 | virtual void setupV0(wl_text_input_manager *textinputmanagerunstablev0) { | ||
86 | Q_UNUSED(textinputmanagerunstablev0) | 106 | Q_UNUSED(textinputmanagerunstablev0) | ||
87 | } | 107 | } | ||
88 | virtual void setupV2(zwp_text_input_manager_v2 *textinputmanagerunstablev2) { | 108 | virtual void setupV2(zwp_text_input_manager_v2 *textinputmanagerunstablev2) { | ||
89 | Q_UNUSED(textinputmanagerunstablev2) | 109 | Q_UNUSED(textinputmanagerunstablev2) | ||
90 | } | 110 | } | ||
111 | virtual void setupV3(zwp_text_input_manager_v3 *textinputmanagerunstablev3) { | ||||
112 | Q_UNUSED(textinputmanagerunstablev3) | ||||
113 | } | ||||
91 | virtual TextInput *createTextInput(Seat *seat, QObject *parent = nullptr) = 0; | 114 | virtual TextInput *createTextInput(Seat *seat, QObject *parent = nullptr) = 0; | ||
92 | virtual operator wl_text_input_manager*() { | 115 | virtual operator wl_text_input_manager*() { | ||
93 | return nullptr; | 116 | return nullptr; | ||
94 | } | 117 | } | ||
95 | virtual operator wl_text_input_manager*() const { | 118 | virtual operator wl_text_input_manager*() const { | ||
96 | return nullptr; | 119 | return nullptr; | ||
97 | } | 120 | } | ||
98 | virtual operator zwp_text_input_manager_v2*() { | 121 | virtual operator zwp_text_input_manager_v2*() { | ||
99 | return nullptr; | 122 | return nullptr; | ||
100 | } | 123 | } | ||
101 | virtual operator zwp_text_input_manager_v2*() const { | 124 | virtual operator zwp_text_input_manager_v2*() const { | ||
102 | return nullptr; | 125 | return nullptr; | ||
103 | } | 126 | } | ||
127 | virtual operator zwp_text_input_manager_v3*() { | ||||
128 | return nullptr; | ||||
129 | } | ||||
130 | virtual operator zwp_text_input_manager_v3*() const { | ||||
131 | return nullptr; | ||||
132 | } | ||||
104 | 133 | | |||
105 | EventQueue *queue = nullptr; | 134 | EventQueue *queue = nullptr; | ||
106 | }; | 135 | }; | ||
107 | 136 | | |||
108 | class Q_DECL_HIDDEN TextInput::Private | 137 | class Q_DECL_HIDDEN TextInput::Private | ||
109 | { | 138 | { | ||
110 | public: | 139 | public: | ||
111 | Private(Seat *seat); | 140 | Private(Seat *seat); | ||
112 | virtual ~Private() = default; | 141 | virtual ~Private() = default; | ||
113 | 142 | | |||
114 | virtual bool isValid() const = 0; | 143 | virtual bool isValid() const = 0; | ||
115 | virtual void enable(Surface *surface) = 0; | 144 | virtual void enable(Surface *surface) = 0; | ||
116 | virtual void disable(Surface *surface) = 0; | 145 | virtual void disable(Surface *surface) = 0; | ||
117 | virtual void showInputPanel() = 0; | 146 | virtual void showInputPanel() = 0; | ||
118 | virtual void hideInputPanel() = 0; | 147 | virtual void hideInputPanel() = 0; | ||
119 | virtual void setCursorRectangle(const QRect &rect) = 0; | 148 | virtual void setCursorRectangle(const QRect &rect) = 0; | ||
120 | virtual void setPreferredLanguage(const QString &lang) = 0; | 149 | virtual void setPreferredLanguage(const QString &lang) = 0; | ||
150 | virtual void setSurroundingTextChangeCause(ChangeCause cause); | ||||
121 | virtual void setSurroundingText(const QString &text, quint32 cursor, quint32 anchor) = 0; | 151 | virtual void setSurroundingText(const QString &text, quint32 cursor, quint32 anchor) = 0; | ||
122 | virtual void reset() = 0; | 152 | virtual void reset() = 0; | ||
123 | virtual void setContentType(ContentHints hint, ContentPurpose purpose) = 0; | 153 | virtual void setContentType(ContentHints hint, ContentPurpose purpose) = 0; | ||
154 | virtual void commit(); | ||||
124 | 155 | | |||
125 | EventQueue *queue = nullptr; | 156 | EventQueue *queue = nullptr; | ||
126 | Seat *seat; | 157 | Seat *seat; | ||
127 | Surface *enteredSurface = nullptr; | 158 | Surface *enteredSurface = nullptr; | ||
128 | quint32 latestSerial = 0; | 159 | quint32 latestSerial = 0; | ||
129 | bool inputPanelVisible = false; | 160 | bool inputPanelVisible = false; | ||
130 | Qt::LayoutDirection textDirection = Qt::LayoutDirectionAuto; | 161 | Qt::LayoutDirection textDirection = Qt::LayoutDirectionAuto; | ||
131 | QByteArray language; | 162 | QByteArray language; | ||
132 | 163 | | |||
133 | struct PreEdit { | 164 | struct PreEdit { | ||
134 | QByteArray text; | 165 | QByteArray text; | ||
135 | QByteArray commitText; | 166 | QByteArray commitText; | ||
136 | qint32 cursor = 0; | 167 | qint32 cursor = 0; | ||
168 | qint32 cursorEnd = 0; | ||||
137 | bool cursorSet = false; | 169 | bool cursorSet = false; | ||
138 | }; | 170 | }; | ||
139 | PreEdit currentPreEdit; | 171 | PreEdit currentPreEdit; | ||
140 | PreEdit pendingPreEdit; | 172 | PreEdit pendingPreEdit; | ||
141 | 173 | | |||
142 | struct Commit { | 174 | struct Commit { | ||
143 | QByteArray text; | 175 | QByteArray text; | ||
176 | bool textSet = false; | ||||
177 | QByteArray surroundingText; | ||||
144 | qint32 cursor = 0; | 178 | qint32 cursor = 0; | ||
145 | qint32 anchor = 0; | 179 | qint32 anchor = 0; | ||
146 | DeleteSurroundingText deleteSurrounding; | 180 | DeleteSurroundingText deleteSurrounding; | ||
147 | }; | 181 | }; | ||
148 | Commit currentCommit; | 182 | Commit currentCommit; | ||
149 | Commit pendingCommit; | 183 | Commit pendingCommit; | ||
150 | }; | 184 | }; | ||
151 | 185 | | |||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | 234 | public: | |||
234 | operator zwp_text_input_v2*(); | 268 | operator zwp_text_input_v2*(); | ||
235 | operator zwp_text_input_v2*() const; | 269 | operator zwp_text_input_v2*() const; | ||
236 | 270 | | |||
237 | private: | 271 | private: | ||
238 | class Private; | 272 | class Private; | ||
239 | Private *d_func() const; | 273 | Private *d_func() const; | ||
240 | }; | 274 | }; | ||
241 | 275 | | |||
276 | class TextInputUnstableV3 : public TextInput | ||||
277 | { | ||||
278 | Q_OBJECT | ||||
279 | public: | ||||
280 | explicit TextInputUnstableV3(Seat *seat, QObject *parent = nullptr); | ||||
281 | virtual ~TextInputUnstableV3(); | ||||
282 | | ||||
283 | /** | ||||
284 | * Setup this TextInputUnstableV3 to manage the @p textinputunstablev3. | ||||
285 | * When using TextInputManagerUnstableV3::createTextInputUnstableV3 there is no need to call this | ||||
286 | * method. | ||||
287 | **/ | ||||
288 | void setup(zwp_text_input_v3 *textinputunstablev3); | ||||
289 | /** | ||||
290 | * Releases the zwp_text_input_v3 interface. | ||||
291 | * After the interface has been released the TextInputUnstableV3 instance is no | ||||
292 | * longer valid and can be setup with another zwp_text_input_v3 interface. | ||||
293 | **/ | ||||
294 | void release(); | ||||
295 | /** | ||||
296 | * Destroys the data held by this TextInputUnstableV3. | ||||
297 | * This method is supposed to be used when the connection to the Wayland | ||||
298 | * server goes away. If the connection is not valid anymore, it's not | ||||
299 | * possible to call release anymore as that calls into the Wayland | ||||
300 | * connection and the call would fail. This method cleans up the data, so | ||||
301 | * that the instance can be deleted or set up to a new zwp_text_input_v3 interface | ||||
302 | * once there is a new connection available. | ||||
303 | * | ||||
304 | * It is suggested to connect this method to ConnectionThread::connectionDied: | ||||
305 | * @code | ||||
306 | * connect(connection, &ConnectionThread::connectionDied, textinputunstablev3, &TextInputUnstableV3::destroy); | ||||
307 | * @endcode | ||||
308 | * | ||||
309 | * @see release | ||||
310 | **/ | ||||
311 | void destroy(); | ||||
312 | | ||||
313 | operator zwp_text_input_v3*(); | ||||
314 | operator zwp_text_input_v3*() const; | ||||
315 | | ||||
316 | private: | ||||
317 | class Private; | ||||
318 | Private *d_func() const; | ||||
319 | }; | ||||
320 | | ||||
242 | } | 321 | } | ||
243 | } | 322 | } | ||
244 | 323 | | |||
245 | #endif | 324 | #endif |
V3?