KWayland

textinput.h
1 /*
2  SPDX-FileCopyrightText: 2016 Martin Gräßlin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #ifndef KWAYLAND_CLIENT_TEXTINPUT_H
7 #define KWAYLAND_CLIENT_TEXTINPUT_H
8 
9 #include <QObject>
10 
11 #include <KWayland/Client/kwaylandclient_export.h>
12 
13 struct wl_text_input;
14 struct wl_text_input_manager;
15 struct zwp_text_input_manager_v2;
16 
17 namespace KWayland
18 {
19 namespace Client
20 {
21 
22 class EventQueue;
23 class TextInputUnstableV0;
24 class Surface;
25 class Seat;
26 
40 class KWAYLANDCLIENT_EXPORT TextInput : public QObject
41 {
42  Q_OBJECT
43 public:
44  virtual ~TextInput();
48  bool isValid() const;
49 
55  Surface *enteredSurface() const;
56 
57  void setEventQueue(EventQueue *queue);
58  EventQueue *eventQueue() const;
59 
64  bool isInputPanelVisible() const;
65 
74  void enable(Surface *surface);
75 
81  void disable(Surface *surface);
82 
87  void showInputPanel();
88 
93  void hideInputPanel();
94 
100  void reset();
101 
109  void setSurroundingText(const QString &text, quint32 cursor, quint32 anchor);
110 
115  enum class KeyState {
116  Pressed,
117  Released
118  };
119 
123  enum class ContentHint : uint32_t {
127  None = 0,
131  AutoCompletion = 1 << 0,
135  AutoCorrection = 1 << 1,
139  AutoCapitalization = 1 << 2,
143  LowerCase = 1 << 3,
147  UpperCase = 1 << 4,
151  TitleCase = 1 << 5,
155  HiddenText = 1 << 6,
159  SensitiveData = 1 << 7,
163  Latin = 1 << 8,
167  MultiLine = 1 << 9
168  };
169  Q_DECLARE_FLAGS(ContentHints, ContentHint)
170 
171 
177  enum class ContentPurpose : uint32_t {
181  Normal,
185  Alpha,
189  Digits,
193  Number,
197  Phone,
201  Url,
205  Email,
209  Name,
213  Password,
217  Date,
221  Time,
225  DateTime,
229  Terminal
230  };
236  void setContentType(ContentHints hints, ContentPurpose purpose);
237 
244  void setCursorRectangle(const QRect &rect);
245 
252  void setPreferredLanguage(const QString &language);
253 
262  Qt::LayoutDirection textDirection() const;
263 
272  QByteArray language() const;
273 
281  qint32 composingTextCursorPosition() const;
282 
288  QByteArray composingText() const;
289 
297  QByteArray composingFallbackText() const;
298 
308  QByteArray commitText() const;
309 
314  qint32 cursorPosition() const;
315 
321  qint32 anchorPosition() const;
322 
327  quint32 beforeLength;
328  quint32 afterLength;
329  };
334  DeleteSurroundingText deleteSurroundingText() const;
335 
336 Q_SIGNALS:
342  void entered();
348  void left();
353  void inputPanelStateChanged();
358  void textDirectionChanged();
363  void languageChanged();
364 
375  void keyEvent(quint32 xkbKeySym, KWayland::Client::TextInput::KeyState state, Qt::KeyboardModifiers modifiers, quint32 time);
376 
383  void composingTextChanged();
384 
395  void committed();
396 
397 protected:
398  class Private;
400  explicit TextInput(Private *p, QObject *parent = nullptr);
401 };
402 
417 class KWAYLANDCLIENT_EXPORT TextInputManager : public QObject
418 {
419  Q_OBJECT
420 public:
421  virtual ~TextInputManager();
422 
428  void setup(wl_text_input_manager *textinputmanagerunstablev0);
434  void setup(zwp_text_input_manager_v2 *textinputmanagerunstablev2);
438  bool isValid() const;
444  void release();
459  void destroy();
460 
464  void setEventQueue(EventQueue *queue);
468  EventQueue *eventQueue();
469 
476  TextInput *createTextInput(Seat *seat, QObject *parent = nullptr);
477 
481  operator wl_text_input_manager*();
485  operator wl_text_input_manager*() const;
489  operator zwp_text_input_manager_v2*();
493  operator zwp_text_input_manager_v2*() const;
494 
495 Q_SIGNALS:
502  void removed();
503 
504 protected:
505  class Private;
506  explicit TextInputManager(Private *p, QObject *parent = nullptr);
507 
509 };
510 
511 }
512 }
513 
514 Q_DECLARE_METATYPE(KWayland::Client::TextInput::KeyState)
518 Q_DECLARE_OPERATORS_FOR_FLAGS(KWayland::Client::TextInput::ContentHints)
519 
520 #endif
ContentHint
ContentHint allows to modify the behavior of the text input.
Definition: textinput.h:123
typedef KeyboardModifiers
ContentPurpose
The ContentPurpose allows to specify the primary purpose of a text input.
Definition: textinput.h:177
Holds the length before and after the cursor position to be deleted.
Definition: textinput.h:326
Manager class for the TextInputManager interfaces.
Definition: textinput.h:417
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:55
Wrapper for the wl_seat interface.
Definition: seat.h:52
LayoutDirection
Wrapper for the wl_surface interface.
Definition: surface.h:44
TextInput represents a Wayland interface for text input.
Definition: textinput.h:40
KeyState
The possible states for a keyEvent.
Definition: textinput.h:115
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 14 2020 22:49:59 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.