KWaylandServer

inputmethod_v1_interface.h
1 /*
2  SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #pragma once
8 
9 #include <KWaylandServer/kwaylandserver_export.h>
10 
11 #include <QObject>
12 #include <QVector>
13 
14 #include "textinput.h"
15 
16 namespace KWaylandServer
17 {
18 class OutputInterface;
19 class SurfaceInterface;
20 class Display;
21 class KeyboardInterface;
22 class InputPanelSurfaceV1Interface;
23 class InputMethodContextV1Interface;
24 
25 class InputMethodV1InterfacePrivate;
26 class InputMethodContextV1InterfacePrivate;
27 class InputPanelV1InterfacePrivate;
28 class InputPanelSurfaceV1InterfacePrivate;
29 class InputMethodGrabV1;
30 class InputKeyboardV1InterfacePrivate;
31 
32 enum class KeyboardKeyState : quint32;
33 
34 // This file's classes implment input_method_unstable_v1
35 
36 /**
37  * Implements zwp_input_method_v1 and allows to activate and deactivate a context
38  *
39  * When we activate, an @class InputMethodContextV1Interface becomes available
40  */
41 class KWAYLANDSERVER_EXPORT InputMethodV1Interface : public QObject
42 {
43  Q_OBJECT
44 public:
45  InputMethodV1Interface(Display *d, QObject *parent);
46  ~InputMethodV1Interface() override;
47 
48  /**
49  * Activates the input method.
50  */
51  void sendActivate();
52 
53  /**
54  * Deactivates the input method, probably because we're not on some area
55  * where we can write text.
56  */
57  void sendDeactivate();
58 
59  InputMethodContextV1Interface *context() const;
60 
61 private:
63 };
64 
65 /**
66  * Implements zwp_input_method_context_v1, allows to describe the client's input state
67  */
68 class KWAYLANDSERVER_EXPORT InputMethodContextV1Interface : public QObject
69 {
70  Q_OBJECT
71 public:
73 
74  void sendSurroundingText(const QString &text, quint32 cursor, quint32 anchor);
75  void sendReset();
76  void sendContentType(KWaylandServer::TextInputContentHints hint, KWaylandServer::TextInputContentPurpose purpose);
77  void sendInvokeAction(quint32 button, quint32 index);
78  void sendCommitState(quint32 serial);
79  void sendPreferredLanguage(const QString &language);
80 
81  InputMethodGrabV1 *keyboardGrab() const;
82 
83 Q_SIGNALS:
84  void commitString(quint32 serial, const QString &text);
85  void preeditString(quint32 serial, const QString &text, const QString &commit);
86  void preeditStyling(quint32 index, quint32 length, quint32 style);
87  void preeditCursor(qint32 index);
88  void deleteSurroundingText(qint32 index, quint32 length);
89  void cursorPosition(qint32 index, qint32 anchor);
90  void keysym(quint32 serial, quint32 time, quint32 sym, bool pressed, quint32 modifiers);
91  void key(quint32 serial, quint32 time, quint32 key, bool pressed);
92  void modifiers(quint32 serial, quint32 mods_depressed, quint32 mods_latched, quint32 mods_locked, quint32 group);
93  void language(quint32 serial, const QString &language);
94  void textDirection(quint32 serial, Qt::LayoutDirection direction);
95  void keyboardGrabRequested(InputMethodGrabV1 *keyboardGrab);
96  void modifiersMap(const QByteArray &map);
97 
98 private:
99  friend class InputMethodV1Interface;
100  friend class InputMethodV1InterfacePrivate;
101  InputMethodContextV1Interface(InputMethodV1Interface *parent);
103 };
104 
105 /**
106  * Implements zwp_input_panel_v1, tells us about the InputPanelSurfaceV1Interface that we might get
107  */
108 class KWAYLANDSERVER_EXPORT InputPanelV1Interface : public QObject
109 {
110  Q_OBJECT
111 public:
112  InputPanelV1Interface(Display *display, QObject *parent);
113  ~InputPanelV1Interface() override;
114 
115 Q_SIGNALS:
116  void inputPanelSurfaceAdded(InputPanelSurfaceV1Interface *surface);
117 
118 private:
120 };
121 
122 /**
123  * Implements zwp_input_panel_surface_v1, it corresponds to each element shown so it can be placed.
124  */
125 class KWAYLANDSERVER_EXPORT InputPanelSurfaceV1Interface : public QObject
126 {
127  Q_OBJECT
128 public:
129  ~InputPanelSurfaceV1Interface() override;
130 
131  enum Position {
132  CenterBottom = 0,
133  };
134  Q_ENUM(Position)
135 
136  SurfaceInterface *surface() const;
137 
138 Q_SIGNALS:
139  void topLevel(OutputInterface *output, Position position);
140  void overlayPanel();
141 
142 private:
143  InputPanelSurfaceV1Interface(SurfaceInterface *surface, quint32 id, QObject *parent);
144  friend class InputPanelV1InterfacePrivate;
146 };
147 
148 /**
149  * Implements a wl_keyboard tailored for zwp_input_method_v1 use-cases
150  */
151 class KWAYLANDSERVER_EXPORT InputMethodGrabV1 : public QObject
152 {
153  Q_OBJECT
154 public:
155  ~InputMethodGrabV1() override;
156 
157  void sendKeymap(const QByteArray &content);
158  void sendKey(quint32 serial, quint32 timestamp, quint32 key, KeyboardKeyState state);
159  void sendModifiers(quint32 serial, quint32 depressed, quint32 latched, quint32 locked, quint32 group);
160 
161 private:
162  InputMethodGrabV1(QObject *parent);
163  friend class InputPanelV1InterfacePrivate;
164  friend class InputMethodContextV1InterfacePrivate;
166 };
167 
168 }
169 
170 Q_DECLARE_METATYPE(KWaylandServer::InputMethodV1Interface *)
171 Q_DECLARE_METATYPE(KWaylandServer::InputMethodGrabV1 *)
The OutputInterface class represents a screen.
Class holding the Wayland server display loop.
Definition: display.h:47
LayoutDirection
Implements zwp_input_method_context_v1, allows to describe the client&#39;s input state.
Implements zwp_input_panel_surface_v1, it corresponds to each element shown so it can be placed...
Implements a wl_keyboard tailored for zwp_input_method_v1 use-cases.
Resource representing a wl_surface.
Implements zwp_input_panel_v1, tells us about the InputPanelSurfaceV1Interface that we might get...
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 16 2021 23:10:14 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.