Changeset View
Changeset View
Standalone View
Standalone View
src/server/textinput_interface.h
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 43 | enum class TextInputInterfaceVersion { | |||
---|---|---|---|---|---|
47 | UnstableV0, | 47 | UnstableV0, | ||
48 | /** | 48 | /** | ||
49 | * not supported version | 49 | * not supported version | ||
50 | **/ | 50 | **/ | ||
51 | UnstableV1, | 51 | UnstableV1, | ||
52 | /** | 52 | /** | ||
53 | * zwp_text_input_v2 as used by Qt 5.7 | 53 | * zwp_text_input_v2 as used by Qt 5.7 | ||
54 | **/ | 54 | **/ | ||
55 | UnstableV2 | 55 | UnstableV2, | ||
56 | /** | ||||
57 | * zwp_text_input_v3, not yet used by Qt | ||||
58 | **/ | ||||
59 | UnstableV3 | ||||
56 | }; | 60 | }; | ||
57 | 61 | | |||
58 | /** | 62 | /** | ||
59 | * @brief Represent the Global for the interface. | 63 | * @brief Represent the Global for the interface. | ||
60 | * | 64 | * | ||
61 | * The class can represent different interfaces. Which concrete interface is represented | 65 | * The class can represent different interfaces. Which concrete interface is represented | ||
62 | * can be determined through {@link interfaceVersion}. | 66 | * can be determined through {@link interfaceVersion}. | ||
63 | * | 67 | * | ||
Show All 40 Lines | |||||
104 | **/ | 108 | **/ | ||
105 | class KWAYLANDSERVER_EXPORT TextInputInterface : public Resource | 109 | class KWAYLANDSERVER_EXPORT TextInputInterface : public Resource | ||
106 | { | 110 | { | ||
107 | Q_OBJECT | 111 | Q_OBJECT | ||
108 | public: | 112 | public: | ||
109 | virtual ~TextInputInterface(); | 113 | virtual ~TextInputInterface(); | ||
110 | 114 | | |||
111 | /** | 115 | /** | ||
116 | * ChangeCause allows to specify the reason for a change | ||||
117 | * of the surrounding text or cursor position. | ||||
118 | */ | ||||
119 | enum class ChangeCause : uint32_t { | ||||
120 | /** | ||||
121 | * input method caused change | ||||
122 | */ | ||||
123 | InputMethod, | ||||
124 | /** | ||||
125 | * something else than input method caused change | ||||
126 | */ | ||||
127 | Other | ||||
128 | }; | ||||
129 | | ||||
130 | /** | ||||
112 | * ContentHint allows to modify the behavior of the text input. | 131 | * ContentHint allows to modify the behavior of the text input. | ||
113 | **/ | 132 | **/ | ||
114 | enum class ContentHint : uint32_t { | 133 | enum class ContentHint : uint32_t { | ||
115 | /** | 134 | /** | ||
116 | * no special behaviour | 135 | * no special behaviour | ||
117 | */ | 136 | */ | ||
118 | None = 0, | 137 | None = 0, | ||
119 | /** | 138 | /** | ||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 187 | enum class ContentPurpose : uint32_t { | |||
198 | * input a name of a person | 217 | * input a name of a person | ||
199 | */ | 218 | */ | ||
200 | Name, | 219 | Name, | ||
201 | /** | 220 | /** | ||
202 | * input a password | 221 | * input a password | ||
203 | */ | 222 | */ | ||
204 | Password, | 223 | Password, | ||
205 | /** | 224 | /** | ||
225 | * input a numeric password | ||||
226 | * @since 5.XX | ||||
227 | */ | ||||
228 | Pin, | ||||
229 | /** | ||||
206 | * input a date | 230 | * input a date | ||
207 | */ | 231 | */ | ||
208 | Date, | 232 | Date, | ||
209 | /** | 233 | /** | ||
210 | * input a time | 234 | * input a time | ||
211 | */ | 235 | */ | ||
212 | Time, | 236 | Time, | ||
213 | /** | 237 | /** | ||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
267 | * If there is no selected text this is the same as cursor. | 291 | * If there is no selected text this is the same as cursor. | ||
268 | * @return The byte offset of the selection anchor | 292 | * @return The byte offset of the selection anchor | ||
269 | * @see surroundingText | 293 | * @see surroundingText | ||
270 | * @see surroundingTextChanged | 294 | * @see surroundingTextChanged | ||
271 | **/ | 295 | **/ | ||
272 | qint32 surroundingTextSelectionAnchor() const; | 296 | qint32 surroundingTextSelectionAnchor() const; | ||
273 | 297 | | |||
274 | /** | 298 | /** | ||
299 | * The cause of the latest surrounding text change. | ||||
300 | * | ||||
301 | * @see surroundingText | ||||
302 | * @see surroundingTextChanged | ||||
303 | **/ | ||||
304 | ChangeCause surroundingTextChangeCause() const; | ||||
305 | | ||||
306 | /** | ||||
275 | * @return The surface the TextInputInterface is enabled on | 307 | * @return The surface the TextInputInterface is enabled on | ||
276 | * @see isEnabled | 308 | * @see isEnabled | ||
277 | * @see enabledChanged | 309 | * @see enabledChanged | ||
278 | **/ | 310 | **/ | ||
279 | QPointer<SurfaceInterface> surface() const; | 311 | QPointer<SurfaceInterface> surface() const; | ||
280 | 312 | | |||
281 | /** | 313 | /** | ||
282 | * @return Whether the TextInputInterface is currently enabled for a SurfaceInterface. | 314 | * @return Whether the TextInputInterface is currently enabled for a SurfaceInterface. | ||
Show All 13 Lines | |||||
296 | * @param text The new utf8-encoded pre-edit text | 328 | * @param text The new utf8-encoded pre-edit text | ||
297 | * @param commitText Utf8-encoded text to replace preedit text on reset | 329 | * @param commitText Utf8-encoded text to replace preedit text on reset | ||
298 | * @see commit | 330 | * @see commit | ||
299 | * @see preEditCursor | 331 | * @see preEditCursor | ||
300 | **/ | 332 | **/ | ||
301 | void preEdit(const QByteArray &text, const QByteArray &commitText); | 333 | void preEdit(const QByteArray &text, const QByteArray &commitText); | ||
302 | 334 | | |||
303 | /** | 335 | /** | ||
336 | * Notify when a new composing @p text (pre-edit) should be set around the | ||||
337 | * current cursor position. Any previously set composing text should | ||||
338 | * be removed. | ||||
339 | * | ||||
340 | * @param text The new utf8-encoded pre-edit text | ||||
341 | * @see commit | ||||
342 | * @see preEditCursor | ||||
343 | * @since 5.XX | ||||
344 | **/ | ||||
345 | void preEdit(const QByteArray &text); | ||||
346 | | ||||
347 | /** | ||||
304 | * Notify when @p text should be inserted into the editor widget. | 348 | * Notify when @p text should be inserted into the editor widget. | ||
305 | * The text to commit could be either just a single character after a key press or the | 349 | * The text to commit could be either just a single character after a key press or the | ||
306 | * result of some composing ({@link preEdit}). It could be also an empty text | 350 | * result of some composing ({@link preEdit}). It could be also an empty text | ||
307 | * when some text should be removed (see {@link deleteSurroundingText}) or when | 351 | * when some text should be removed (see {@link deleteSurroundingText}) or when | ||
308 | * the input cursor should be moved (see {@link cursorPosition}). | 352 | * the input cursor should be moved (see {@link cursorPosition}). | ||
309 | * | 353 | * | ||
310 | * Any previously set composing text should be removed. | 354 | * Any previously set composing text should be removed. | ||
311 | * @param text The utf8-encoded text to be inserted into the editor widget | 355 | * @param text The utf8-encoded text to be inserted into the editor widget | ||
312 | * @see preEdit | 356 | * @see preEdit | ||
313 | * @see deleteSurroundingText | 357 | * @see deleteSurroundingText | ||
314 | **/ | 358 | **/ | ||
315 | void commit(const QByteArray &text); | 359 | void commit(const QByteArray &text); | ||
316 | 360 | | |||
317 | /** | 361 | /** | ||
318 | * Sets the cursor position inside the composing text (as byte offset) relative to the | 362 | * Sets the cursor position inside the composing text (as byte offset) relative to the | ||
319 | * start of the composing text. When @p index is a negative number no cursor is shown. | 363 | * start of the composing text. When @p index is a negative number no cursor is shown. | ||
320 | * | 364 | * | ||
321 | * The Client applies the @p index together with {@link preEdit}. | 365 | * The Client applies the @p index together with {@link preEdit}. | ||
322 | * @param index The cursor position relative to the start of the composing text | 366 | * @param index The cursor position relative to the start of the composing text | ||
323 | * @see preEdit | 367 | * @see preEdit | ||
324 | **/ | 368 | **/ | ||
325 | void setPreEditCursor(qint32 index); | 369 | void setPreEditCursor(qint32 index); | ||
326 | 370 | | |||
327 | /** | 371 | /** | ||
372 | * Sets the cursor position inside the composing text (as byte offset) relative to the | ||||
373 | * start of the composing text. When @p begin and end are negative numbers no cursor is | ||||
374 | * shown. | ||||
375 | * | ||||
376 | * If begin and end define a range, the client may underline or otherwise mark the text | ||||
377 | * in that range. | ||||
378 | * | ||||
379 | * The Client applies @p begin and @p end together with {@link preEdit}. | ||||
380 | * @param begin The cursor start relative to the start of the composing text | ||||
381 | * @param end The cursor end relative to the start of the composing text | ||||
382 | * @see preEdit | ||||
383 | * @since 5.XX | ||||
384 | **/ | ||||
385 | void setPreEditCursor(qint32 begin, qint32 end); | ||||
386 | | ||||
387 | /** | ||||
328 | * Notify when the text around the current cursor position should be deleted. | 388 | * Notify when the text around the current cursor position should be deleted. | ||
329 | * | 389 | * | ||
330 | * The Client processes this event together with the commit string | 390 | * The Client processes this event together with the commit string | ||
331 | * | 391 | * | ||
332 | * @param beforeLength length of text before current cursor position. | 392 | * @param beforeLength length of text before current cursor position. | ||
333 | * @param afterLength length of text after current cursor position. | 393 | * @param afterLength length of text after current cursor position. | ||
334 | * @see commit | 394 | * @see commit | ||
335 | **/ | 395 | **/ | ||
Show All 24 Lines | |||||
360 | * @param overlappedSurfaceArea The overlapping area in surface local coordinates | 420 | * @param overlappedSurfaceArea The overlapping area in surface local coordinates | ||
361 | **/ | 421 | **/ | ||
362 | void setInputPanelState(bool visible, const QRect &overlappedSurfaceArea); | 422 | void setInputPanelState(bool visible, const QRect &overlappedSurfaceArea); | ||
363 | 423 | | |||
364 | /** | 424 | /** | ||
365 | * Sets the language of the input text. The @p languageTag is a RFC-3066 format language tag. | 425 | * Sets the language of the input text. The @p languageTag is a RFC-3066 format language tag. | ||
366 | **/ | 426 | **/ | ||
367 | void setLanguage(const QByteArray &languageTag); | 427 | void setLanguage(const QByteArray &languageTag); | ||
428 | /** | ||||
429 | * Instructs the client to apply previous changes | ||||
430 | * @since 5.XX | ||||
431 | **/ | ||||
432 | void done(); | ||||
368 | 433 | | |||
369 | Q_SIGNALS: | 434 | Q_SIGNALS: | ||
370 | /** | 435 | /** | ||
371 | * Requests input panels (virtual keyboard) to show. | 436 | * Requests input panels (virtual keyboard) to show. | ||
372 | * @see requestHideInputPanel | 437 | * @see requestHideInputPanel | ||
373 | **/ | 438 | **/ | ||
374 | void requestShowInputPanel(); | 439 | void requestShowInputPanel(); | ||
375 | /** | 440 | /** | ||
Show All 31 Lines | |||||
407 | **/ | 472 | **/ | ||
408 | void surroundingTextChanged(); | 473 | void surroundingTextChanged(); | ||
409 | /** | 474 | /** | ||
410 | * Emitted whenever this TextInputInterface gets enabled or disabled for a SurfaceInterface. | 475 | * Emitted whenever this TextInputInterface gets enabled or disabled for a SurfaceInterface. | ||
411 | * @see isEnabled | 476 | * @see isEnabled | ||
412 | * @see surface | 477 | * @see surface | ||
413 | **/ | 478 | **/ | ||
414 | void enabledChanged(); | 479 | void enabledChanged(); | ||
480 | /** | ||||
481 | * Emitted whenever the client committed the pending state. | ||||
482 | * | ||||
483 | * This is an atomic alternative to listening for the indvidual changed | ||||
484 | * signals. | ||||
485 | * | ||||
486 | * All affected properties have already been set and can be queried via the | ||||
487 | * respective getters in this interface. | ||||
488 | * | ||||
489 | * Note that this signal differs from listening for individual changed signals | ||||
490 | * only starting with v3 of the text-input protocol. | ||||
491 | * | ||||
492 | * @see isEnabled | ||||
493 | * @see contentPurpose | ||||
494 | * @see contentHints | ||||
495 | * @see cursorRectangle | ||||
496 | * @see surroundingText | ||||
497 | * @see surroundingTextChangeCause | ||||
498 | * @since 5.XX | ||||
499 | **/ | ||||
500 | void committed(); | ||||
415 | 501 | | |||
416 | protected: | 502 | protected: | ||
417 | class Private; | 503 | class Private; | ||
418 | explicit TextInputInterface(Private *p, QObject *parent = nullptr); | 504 | explicit TextInputInterface(Private *p, QObject *parent = nullptr); | ||
419 | 505 | | |||
420 | private: | 506 | private: | ||
421 | friend class TextInputManagerUnstableV0Interface; | 507 | friend class TextInputManagerUnstableV0Interface; | ||
422 | friend class TextInputManagerUnstableV2Interface; | 508 | friend class TextInputManagerUnstableV2Interface; | ||
509 | friend class TextInputManagerUnstableV3Interface; | ||||
423 | friend class SeatInterface; | 510 | friend class SeatInterface; | ||
424 | 511 | | |||
425 | Private *d_func() const; | 512 | Private *d_func() const; | ||
426 | }; | 513 | }; | ||
427 | 514 | | |||
428 | 515 | | |||
429 | } | 516 | } | ||
430 | } | 517 | } | ||
431 | 518 | | |||
432 | Q_DECLARE_METATYPE(KWayland::Server::TextInputInterfaceVersion) | 519 | Q_DECLARE_METATYPE(KWayland::Server::TextInputInterfaceVersion) | ||
433 | Q_DECLARE_METATYPE(KWayland::Server::TextInputInterface *) | 520 | Q_DECLARE_METATYPE(KWayland::Server::TextInputInterface *) | ||
521 | Q_DECLARE_METATYPE(KWayland::Server::TextInputInterface::ChangeCause) | ||||
434 | Q_DECLARE_METATYPE(KWayland::Server::TextInputInterface::ContentHint) | 522 | Q_DECLARE_METATYPE(KWayland::Server::TextInputInterface::ContentHint) | ||
435 | Q_DECLARE_METATYPE(KWayland::Server::TextInputInterface::ContentHints) | 523 | Q_DECLARE_METATYPE(KWayland::Server::TextInputInterface::ContentHints) | ||
436 | Q_DECLARE_OPERATORS_FOR_FLAGS(KWayland::Server::TextInputInterface::ContentHints) | 524 | Q_DECLARE_OPERATORS_FOR_FLAGS(KWayland::Server::TextInputInterface::ContentHints) | ||
437 | Q_DECLARE_METATYPE(KWayland::Server::TextInputInterface::ContentPurpose) | 525 | Q_DECLARE_METATYPE(KWayland::Server::TextInputInterface::ContentPurpose) | ||
438 | 526 | | |||
439 | #endif | 527 | #endif |