1/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2/* vim:set et sts=4: */
3/* ibus - The Input Bus
4 * Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
5 * Copyright (C) 2010-2022 Takao Fujiwara <takao.fujiwara1@gmail.com>
6 * Copyright (C) 2008-2022 Red Hat, Inc.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
21 * USA
22 */
23
24#if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
25#error "Only <ibus.h> can be included directly"
26#endif
27
28#ifndef __IBUS_TYPES_H_
29#define __IBUS_TYPES_H_
30
31/**
32 * SECTION: ibustypes
33 * @short_description: Generic types for IBus.
34 * @stability: Stable
35 *
36 * This section consists generic types for IBus, including shift/control key
37 * modifiers,
38 * and a rectangle structure.
39 */
40
41/**
42 * IBusModifierType:
43 * @IBUS_SHIFT_MASK: Shift is activated.
44 * @IBUS_LOCK_MASK: Cap Lock is locked.
45 * @IBUS_CONTROL_MASK: Control key is activated.
46 * @IBUS_MOD1_MASK: Modifier 1 (Usually Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)) activated.
47 * @IBUS_MOD2_MASK: Modifier 2 (Usually Num_Lock (0x4d)) activated.
48 * @IBUS_MOD3_MASK: Modifier 3 activated.
49 * @IBUS_MOD4_MASK: Modifier 4 (Usually Super_L (0xce), Hyper_L (0xcf)) activated.
50 * @IBUS_MOD5_MASK: Modifier 5 (ISO_Level3_Shift (0x5c), Mode_switch (0xcb)) activated.
51 * @IBUS_BUTTON1_MASK: Mouse button 1 (left) is activated.
52 * @IBUS_BUTTON2_MASK: Mouse button 2 (middle) is activated.
53 * @IBUS_BUTTON3_MASK: Mouse button 3 (right) is activated.
54 * @IBUS_BUTTON4_MASK: Mouse button 4 (scroll up) is activated.
55 * @IBUS_BUTTON5_MASK: Mouse button 5 (scroll down) is activated.
56 * @IBUS_HANDLED_MASK: Handled mask indicates the event has been handled by ibus.
57 * @IBUS_FORWARD_MASK: Forward mask indicates the event has been forward from ibus.
58 * @IBUS_IGNORED_MASK: It is an alias of IBUS_FORWARD_MASK.
59 * @IBUS_SUPER_MASK: Super (Usually Win) key is activated.
60 * @IBUS_HYPER_MASK: Hyper key is activated.
61 * @IBUS_META_MASK: Meta key is activated.
62 * @IBUS_RELEASE_MASK: Key is released.
63 * @IBUS_MODIFIER_MASK: Modifier mask for the all the masks above.
64 *
65 * Handles key modifier such as control, shift and alt and release event.
66 * Note that nits 15 - 25 are currently unused, while bit 29 is used internally.
67 */
68typedef enum
69{
70 IBUS_SHIFT_MASK = 1 << 0,
71 IBUS_LOCK_MASK = 1 << 1,
72 IBUS_CONTROL_MASK = 1 << 2,
73 IBUS_MOD1_MASK = 1 << 3,
74 IBUS_MOD2_MASK = 1 << 4,
75 IBUS_MOD3_MASK = 1 << 5,
76 IBUS_MOD4_MASK = 1 << 6,
77 IBUS_MOD5_MASK = 1 << 7,
78 IBUS_BUTTON1_MASK = 1 << 8,
79 IBUS_BUTTON2_MASK = 1 << 9,
80 IBUS_BUTTON3_MASK = 1 << 10,
81 IBUS_BUTTON4_MASK = 1 << 11,
82 IBUS_BUTTON5_MASK = 1 << 12,
83
84 /* The next few modifiers are used by XKB, so we skip to the end.
85 * Bits 15 - 23 are currently unused. Bit 29 is used internally.
86 */
87
88 /* ibus mask */
89 IBUS_HANDLED_MASK = 1 << 24,
90 IBUS_FORWARD_MASK = 1 << 25,
91 IBUS_IGNORED_MASK = IBUS_FORWARD_MASK,
92
93 IBUS_SUPER_MASK = 1 << 26,
94 IBUS_HYPER_MASK = 1 << 27,
95 IBUS_META_MASK = 1 << 28,
96
97 IBUS_RELEASE_MASK = 1 << 30,
98
99 IBUS_MODIFIER_MASK = 0x5f001fff
100} IBusModifierType;
101
102/**
103 * IBusCapabilite:
104 * @IBUS_CAP_PREEDIT_TEXT: UI is capable to show pre-edit text.
105 * @IBUS_CAP_AUXILIARY_TEXT: UI is capable to show auxiliary text.
106 * @IBUS_CAP_LOOKUP_TABLE: UI is capable to show the lookup table.
107 * @IBUS_CAP_FOCUS: UI is capable to get focus.
108 * @IBUS_CAP_PROPERTY: UI is capable to have property.
109 * @IBUS_CAP_SURROUNDING_TEXT: Client can provide surround text,
110 * or IME can handle surround text.
111 *
112 * Capability flags of UI.
113 */
114typedef enum {
115 IBUS_CAP_PREEDIT_TEXT = 1 << 0,
116 IBUS_CAP_AUXILIARY_TEXT = 1 << 1,
117 IBUS_CAP_LOOKUP_TABLE = 1 << 2,
118 IBUS_CAP_FOCUS = 1 << 3,
119 IBUS_CAP_PROPERTY = 1 << 4,
120 IBUS_CAP_SURROUNDING_TEXT = 1 << 5,
121} IBusCapabilite;
122
123/**
124 * IBusPreeditFocusMode:
125 * @IBUS_ENGINE_PREEDIT_CLEAR: pre-edit text is cleared.
126 * @IBUS_ENGINE_PREEDIT_COMMIT: pre-edit text is committed.
127 *
128 * Pre-edit commit mode when the focus is lost.
129 */
130typedef enum {
131 IBUS_ENGINE_PREEDIT_CLEAR = 0,
132 IBUS_ENGINE_PREEDIT_COMMIT = 1,
133} IBusPreeditFocusMode;
134
135/**
136 * IBusOrientation:
137 * @IBUS_ORIENTATION_HORIZONTAL: Horizontal orientation.
138 * @IBUS_ORIENTATION_VERTICAL: Vertival orientation.
139 * @IBUS_ORIENTATION_SYSTEM: Use ibus global orientation setup.
140 *
141 * Orientation of UI.
142 */
143typedef enum {
144 IBUS_ORIENTATION_HORIZONTAL = 0,
145 IBUS_ORIENTATION_VERTICAL = 1,
146 IBUS_ORIENTATION_SYSTEM = 2,
147} IBusOrientation;
148
149/**
150 * IBusBusNameFlag:
151 * @IBUS_BUS_NAME_FLAG_ALLOW_REPLACEMENT:
152 * same as DBUS_NAME_FLAG_ALLOW_REPLACEMENT
153 * @IBUS_BUS_NAME_FLAG_REPLACE_EXISTING:
154 * same as DBUS_NAME_FLAG_REPLACE_EXISTING
155 * @IBUS_BUS_NAME_FLAG_DO_NOT_QUEUE:
156 * same as DBUS_NAME_FLAG_DO_NOT_QUEUE
157 */
158typedef enum {
159 IBUS_BUS_NAME_FLAG_ALLOW_REPLACEMENT = (1 << 0),
160 IBUS_BUS_NAME_FLAG_REPLACE_EXISTING = (1 << 1),
161 IBUS_BUS_NAME_FLAG_DO_NOT_QUEUE = (1 << 2),
162} IBusBusNameFlag;
163
164/**
165 * IBusBusRequestNameReply:
166 * @IBUS_BUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
167 * same as DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER
168 * @IBUS_BUS_REQUEST_NAME_REPLY_IN_QUEUE:
169 * same as DBUS_REQUEST_NAME_REPLY_IN_QUEUE
170 * @IBUS_BUS_REQUEST_NAME_REPLY_EXISTS:
171 * same as DBUS_REQUEST_NAME_REPLY_EXISTS
172 * @IBUS_BUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
173 * same as DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER
174 */
175typedef enum {
176 IBUS_BUS_REQUEST_NAME_REPLY_PRIMARY_OWNER = 1,
177 IBUS_BUS_REQUEST_NAME_REPLY_IN_QUEUE = 2,
178 IBUS_BUS_REQUEST_NAME_REPLY_EXISTS = 3,
179 IBUS_BUS_REQUEST_NAME_REPLY_ALREADY_OWNER = 4,
180} IBusBusRequestNameReply;
181
182/**
183 * IBusBusStartServiceByNameReply:
184 * @IBUS_BUS_START_REPLY_SUCCESS:
185 * same as DBUS_START_REPLY_SUCCESS
186 * @IBUS_BUS_START_REPLY_ALREADY_RUNNING:
187 * same as DBUS_START_REPLY_ALREADY_RUNNING
188 */
189typedef enum {
190 IBUS_BUS_START_REPLY_SUCCESS = 1,
191 IBUS_BUS_START_REPLY_ALREADY_RUNNING = 2,
192} IBusBusStartServiceByNameReply;
193
194/**
195 * IBusError:
196 * @IBUS_ERROR_NO_ENGINE:
197 * There is no engine associated with input context.
198 * @IBUS_ERROR_NO_CONFIG:
199 * There is no config module running.
200 * @IBUS_ERROR_FAILED:
201 * General failure.
202 */
203typedef enum {
204 IBUS_ERROR_NO_ENGINE,
205 IBUS_ERROR_NO_CONFIG,
206 IBUS_ERROR_FAILED
207} IBusError;
208
209/**
210 * IBusRectangle:
211 * @x: x coordinate.
212 * @y: y coordinate.
213 * @width: width of the rectangle.
214 * @height: height of the renctangl.
215 *
216 * Rectangle definition.
217 */
218typedef struct _IBusRectangle IBusRectangle;
219struct _IBusRectangle {
220 gint x;
221 gint y;
222 gint width;
223 gint height;
224};
225
226/**
227 * IBusFreeFunc:
228 * @object: object to be freed.
229 *
230 * Free function prototype.
231 */
232typedef void (* IBusFreeFunc) (gpointer object);
233
234/**
235 * IBusInputPurpose:
236 * @IBUS_INPUT_PURPOSE_FREE_FORM: Allow any character
237 * @IBUS_INPUT_PURPOSE_ALPHA: Allow only alphabetic characters
238 * @IBUS_INPUT_PURPOSE_DIGITS: Allow only digits
239 * @IBUS_INPUT_PURPOSE_NUMBER: Edited field expects numbers
240 * @IBUS_INPUT_PURPOSE_PHONE: Edited field expects phone number
241 * @IBUS_INPUT_PURPOSE_URL: Edited field expects URL
242 * @IBUS_INPUT_PURPOSE_EMAIL: Edited field expects email address
243 * @IBUS_INPUT_PURPOSE_NAME: Edited field expects the name of a person
244 * @IBUS_INPUT_PURPOSE_PASSWORD: Like @IBUS_INPUT_PURPOSE_FREE_FORM,
245 * but characters are hidden
246 * @IBUS_INPUT_PURPOSE_PIN: Like @IBUS_INPUT_PURPOSE_DIGITS, but
247 * characters are hidden
248 * @IBUS_INPUT_PURPOSE_TERMINAL: Allow any character, in addition to control
249 * codes. Since 1.5.24
250 *
251 * Describes primary purpose of the input context. This information
252 * is particularly useful to implement intelligent behavior in
253 * engines, such as automatic input-mode switch and text prediction.
254 *
255 * Note that the purpose is not meant to impose a totally strict rule
256 * about allowed characters, and does not replace input validation.
257 * It is fine for an on-screen keyboard to let the user override the
258 * character set restriction that is expressed by the purpose. The
259 * application is expected to validate the entry contents, even if
260 * it specified a purpose.
261 *
262 * The difference between @IBUS_INPUT_PURPOSE_DIGITS and
263 * @IBUS_INPUT_PURPOSE_NUMBER is that the former accepts only digits
264 * while the latter also some punctuation (like commas or points, plus,
265 * minus) and ā€œeā€ or ā€œEā€ as in 3.14E+000.
266 *
267 * This enumeration may be extended in the future; engines should
268 * interpret unknown values as 'free form'.
269 *
270 * Since: 1.5.4
271 */
272typedef enum
273{
274 IBUS_INPUT_PURPOSE_FREE_FORM,
275 IBUS_INPUT_PURPOSE_ALPHA,
276 IBUS_INPUT_PURPOSE_DIGITS,
277 IBUS_INPUT_PURPOSE_NUMBER,
278 IBUS_INPUT_PURPOSE_PHONE,
279 IBUS_INPUT_PURPOSE_URL,
280 IBUS_INPUT_PURPOSE_EMAIL,
281 IBUS_INPUT_PURPOSE_NAME,
282 IBUS_INPUT_PURPOSE_PASSWORD,
283 IBUS_INPUT_PURPOSE_PIN,
284 IBUS_INPUT_PURPOSE_TERMINAL
285} IBusInputPurpose;
286
287/**
288 * IBusInputHints:
289 * @IBUS_INPUT_HINT_NONE: No special behaviour suggested
290 * @IBUS_INPUT_HINT_SPELLCHECK: Suggest checking for typos
291 * @IBUS_INPUT_HINT_NO_SPELLCHECK: Suggest not checking for typos
292 * @IBUS_INPUT_HINT_WORD_COMPLETION: Suggest word completion
293 * @IBUS_INPUT_HINT_LOWERCASE: Suggest to convert all text to lowercase
294 * @IBUS_INPUT_HINT_UPPERCASE_CHARS: Suggest to capitalize all text
295 * @IBUS_INPUT_HINT_UPPERCASE_WORDS: Suggest to capitalize the first
296 * character of each word
297 * @IBUS_INPUT_HINT_UPPERCASE_SENTENCES: Suggest to capitalize the
298 * first word of each sentence
299 * @IBUS_INPUT_HINT_INHIBIT_OSK: Suggest to not show an onscreen keyboard
300 * (e.g for a calculator that already has all the keys).
301 * @IBUS_INPUT_HINT_VERTICAL_WRITING: The text is vertical. Since 1.5.11
302 * @IBUS_INPUT_HINT_EMOJI: Suggest offering Emoji support. Since 1.5.24
303 * @IBUS_INPUT_HINT_NO_EMOJI: Suggest not offering Emoji support. Since 1.5.24
304 * @IBUS_INPUT_HINT_PRIVATE: Request that the input method should not
305 * update personalized data (like typing history). Since 1.5.26
306 *
307 * Describes hints that might be taken into account by engines. Note
308 * that engines may already tailor their behaviour according to the
309 * #IBusInputPurpose of the entry.
310 *
311 * Some common sense is expected when using these flags - mixing
312 * @IBUS_INPUT_HINT_LOWERCASE with any of the uppercase hints makes no sense.
313 *
314 * This enumeration may be extended in the future; engines should
315 * ignore unknown values.
316 *
317 * Since: 1.5.4
318 */
319typedef enum
320{
321 IBUS_INPUT_HINT_NONE = 0,
322 IBUS_INPUT_HINT_SPELLCHECK = 1 << 0,
323 IBUS_INPUT_HINT_NO_SPELLCHECK = 1 << 1,
324 IBUS_INPUT_HINT_WORD_COMPLETION = 1 << 2,
325 IBUS_INPUT_HINT_LOWERCASE = 1 << 3,
326 IBUS_INPUT_HINT_UPPERCASE_CHARS = 1 << 4,
327 IBUS_INPUT_HINT_UPPERCASE_WORDS = 1 << 5,
328 IBUS_INPUT_HINT_UPPERCASE_SENTENCES = 1 << 6,
329 IBUS_INPUT_HINT_INHIBIT_OSK = 1 << 7,
330 IBUS_INPUT_HINT_VERTICAL_WRITING = 1 << 8,
331 IBUS_INPUT_HINT_EMOJI = 1 << 9,
332 IBUS_INPUT_HINT_NO_EMOJI = 1 << 10,
333 IBUS_INPUT_HINT_PRIVATE = 1 << 11
334} IBusInputHints;
335
336#endif
337
338