1 | /* |
2 | SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
5 | */ |
6 | #include "textinput_p.h" |
7 | |
8 | namespace KWayland |
9 | { |
10 | namespace Client |
11 | { |
12 | TextInput::Private::Private(Seat *seat) |
13 | : seat(seat) |
14 | { |
15 | currentCommit.deleteSurrounding.afterLength = 0; |
16 | currentCommit.deleteSurrounding.beforeLength = 0; |
17 | pendingCommit.deleteSurrounding.afterLength = 0; |
18 | pendingCommit.deleteSurrounding.beforeLength = 0; |
19 | } |
20 | |
21 | TextInput::TextInput(Private *p, QObject *parent) |
22 | : QObject(parent) |
23 | , d(p) |
24 | { |
25 | } |
26 | |
27 | TextInput::~TextInput() = default; |
28 | |
29 | void TextInput::setEventQueue(EventQueue *queue) |
30 | { |
31 | d->queue = queue; |
32 | } |
33 | |
34 | EventQueue *TextInput::eventQueue() const |
35 | { |
36 | return d->queue; |
37 | } |
38 | |
39 | bool TextInput::isValid() const |
40 | { |
41 | return d->isValid(); |
42 | } |
43 | |
44 | Surface *TextInput::enteredSurface() const |
45 | { |
46 | return d->enteredSurface; |
47 | } |
48 | |
49 | bool TextInput::isInputPanelVisible() const |
50 | { |
51 | return d->inputPanelVisible; |
52 | } |
53 | |
54 | void TextInput::enable(Surface *surface) |
55 | { |
56 | d->enable(surface); |
57 | } |
58 | |
59 | void TextInput::disable(Surface *surface) |
60 | { |
61 | d->disable(surface); |
62 | } |
63 | |
64 | void TextInput::showInputPanel() |
65 | { |
66 | d->showInputPanel(); |
67 | } |
68 | |
69 | void TextInput::hideInputPanel() |
70 | { |
71 | d->hideInputPanel(); |
72 | } |
73 | |
74 | void TextInput::reset() |
75 | { |
76 | d->reset(); |
77 | } |
78 | |
79 | void TextInput::setSurroundingText(const QString &text, quint32 cursor, quint32 anchor) |
80 | { |
81 | d->setSurroundingText(text, cursor, anchor); |
82 | } |
83 | |
84 | void TextInput::setContentType(ContentHints hint, ContentPurpose purpose) |
85 | { |
86 | d->setContentType(hint, purpose); |
87 | } |
88 | |
89 | void TextInput::setCursorRectangle(const QRect &rect) |
90 | { |
91 | d->setCursorRectangle(rect); |
92 | } |
93 | |
94 | void TextInput::setPreferredLanguage(const QString &language) |
95 | { |
96 | d->setPreferredLanguage(language); |
97 | } |
98 | |
99 | Qt::LayoutDirection TextInput::textDirection() const |
100 | { |
101 | return d->textDirection; |
102 | } |
103 | |
104 | QByteArray TextInput::language() const |
105 | { |
106 | return d->language; |
107 | } |
108 | |
109 | qint32 TextInput::composingTextCursorPosition() const |
110 | { |
111 | return d->currentPreEdit.cursor; |
112 | } |
113 | |
114 | QByteArray TextInput::composingText() const |
115 | { |
116 | return d->currentPreEdit.text; |
117 | } |
118 | |
119 | QByteArray TextInput::composingFallbackText() const |
120 | { |
121 | return d->currentPreEdit.commitText; |
122 | } |
123 | |
124 | qint32 TextInput::anchorPosition() const |
125 | { |
126 | return d->currentCommit.anchor; |
127 | } |
128 | |
129 | qint32 TextInput::cursorPosition() const |
130 | { |
131 | return d->currentCommit.cursor; |
132 | } |
133 | |
134 | TextInput::DeleteSurroundingText TextInput::deleteSurroundingText() const |
135 | { |
136 | return d->currentCommit.deleteSurrounding; |
137 | } |
138 | |
139 | QByteArray TextInput::commitText() const |
140 | { |
141 | return d->currentCommit.text; |
142 | } |
143 | |
144 | TextInputManager::TextInputManager(Private *p, QObject *parent) |
145 | : QObject(parent) |
146 | , d(p) |
147 | { |
148 | } |
149 | |
150 | TextInputManager::~TextInputManager() = default; |
151 | |
152 | void TextInputManager::setup(wl_text_input_manager *textinputmanagerunstablev0) |
153 | { |
154 | d->setupV0(textinputmanagerunstablev0); |
155 | } |
156 | |
157 | void TextInputManager::setup(zwp_text_input_manager_v2 *textinputmanagerunstablev2) |
158 | { |
159 | d->setupV2(textinputmanagerunstablev2); |
160 | } |
161 | |
162 | void TextInputManager::release() |
163 | { |
164 | d->release(); |
165 | } |
166 | |
167 | void TextInputManager::destroy() |
168 | { |
169 | d->destroy(); |
170 | } |
171 | |
172 | void TextInputManager::setEventQueue(EventQueue *queue) |
173 | { |
174 | d->queue = queue; |
175 | } |
176 | |
177 | EventQueue *TextInputManager::eventQueue() |
178 | { |
179 | return d->queue; |
180 | } |
181 | |
182 | TextInputManager::operator wl_text_input_manager *() |
183 | { |
184 | return *(d.data()); |
185 | } |
186 | |
187 | TextInputManager::operator wl_text_input_manager *() const |
188 | { |
189 | return *(d.data()); |
190 | } |
191 | |
192 | TextInputManager::operator zwp_text_input_manager_v2 *() |
193 | { |
194 | return *(d.data()); |
195 | } |
196 | |
197 | TextInputManager::operator zwp_text_input_manager_v2 *() const |
198 | { |
199 | return *(d.data()); |
200 | } |
201 | |
202 | bool TextInputManager::isValid() const |
203 | { |
204 | return d->isValid(); |
205 | } |
206 | |
207 | TextInput *TextInputManager::createTextInput(Seat *seat, QObject *parent) |
208 | { |
209 | return d->createTextInput(seat, parent); |
210 | } |
211 | |
212 | } |
213 | } |
214 | |
215 | #include "moc_textinput.cpp" |
216 | #include "moc_textinput_p.cpp" |
217 | |