2 * Copyright © 2012, 2013 Intel Corporation
4 * Permission to use, copy, modify, distribute, and sell this
5 * software and its documentation for any purpose is hereby granted
6 * without fee, provided that the above copyright notice appear in
7 * all copies and that both that copyright notice and this permission
8 * notice appear in supporting documentation, and that the name of
9 * the copyright holders not be used in advertising or publicity
10 * pertaining to distribution of the software without specific,
11 * written prior permission. The copyright holders make no
12 * representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
21 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
22 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
26 #ifndef INPUT_METHOD_CLIENT_PROTOCOL_H
27 #define INPUT_METHOD_CLIENT_PROTOCOL_H
35 #include "wayland-client.h"
40 struct wl_input_method_context;
41 struct wl_input_method;
42 struct wl_input_panel;
43 struct wl_input_panel_surface;
45 extern const struct wl_interface wl_input_method_context_interface;
46 extern const struct wl_interface wl_input_method_interface;
47 extern const struct wl_interface wl_input_panel_interface;
48 extern const struct wl_interface wl_input_panel_surface_interface;
51 * wl_input_method_context - input method context
52 * @surrounding_text: surrounding text event
54 * @content_type: (none)
55 * @invoke_action: (none)
56 * @commit_state: (none)
57 * @preferred_language: (none)
59 * Corresponds to a text model on input method side. An input method
60 * context is created on text mode activation on the input method side. It
61 * allows to receive information about the text model from the application
62 * via events. Input method contexts do not keep state after deactivation
63 * and should be destroyed after deactivation is handled.
65 * Text is generally UTF-8 encoded, indices and lengths are in bytes.
67 * Serials are used to synchronize the state between the text input and an
68 * input method. New serials are sent by the text input in the commit_state
69 * request and are used by the input method to indicate the known text
70 * input state in events like preedit_string, commit_string, and keysym.
71 * The text input can then ignore events from the input method which are
72 * based on an outdated state (for example after a reset).
74 struct wl_input_method_context_listener {
76 * surrounding_text - surrounding text event
81 * The plain surrounding text around the input position. Cursor
82 * is the position in bytes within the surrounding text relative to
83 * the beginning of the text. Anchor is the position in bytes of
84 * the selection anchor within the surrounding text relative to the
85 * beginning of the text. If there is no selected text anchor is
88 void (*surrounding_text)(void *data,
89 struct wl_input_method_context *wl_input_method_context,
96 void (*reset)(void *data,
97 struct wl_input_method_context *wl_input_method_context);
99 * content_type - (none)
103 void (*content_type)(void *data,
104 struct wl_input_method_context *wl_input_method_context,
108 * invoke_action - (none)
112 void (*invoke_action)(void *data,
113 struct wl_input_method_context *wl_input_method_context,
117 * commit_state - (none)
118 * @serial: serial of text input state
120 void (*commit_state)(void *data,
121 struct wl_input_method_context *wl_input_method_context,
124 * preferred_language - (none)
127 void (*preferred_language)(void *data,
128 struct wl_input_method_context *wl_input_method_context,
129 const char *language);
133 wl_input_method_context_add_listener(struct wl_input_method_context *wl_input_method_context,
134 const struct wl_input_method_context_listener *listener, void *data)
136 return wl_proxy_add_listener((struct wl_proxy *) wl_input_method_context,
137 (void (**)(void)) listener, data);
140 #define WL_INPUT_METHOD_CONTEXT_DESTROY 0
141 #define WL_INPUT_METHOD_CONTEXT_COMMIT_STRING 1
142 #define WL_INPUT_METHOD_CONTEXT_PREEDIT_STRING 2
143 #define WL_INPUT_METHOD_CONTEXT_PREEDIT_STYLING 3
144 #define WL_INPUT_METHOD_CONTEXT_PREEDIT_CURSOR 4
145 #define WL_INPUT_METHOD_CONTEXT_DELETE_SURROUNDING_TEXT 5
146 #define WL_INPUT_METHOD_CONTEXT_CURSOR_POSITION 6
147 #define WL_INPUT_METHOD_CONTEXT_MODIFIERS_MAP 7
148 #define WL_INPUT_METHOD_CONTEXT_KEYSYM 8
149 #define WL_INPUT_METHOD_CONTEXT_GRAB_KEYBOARD 9
150 #define WL_INPUT_METHOD_CONTEXT_KEY 10
151 #define WL_INPUT_METHOD_CONTEXT_MODIFIERS 11
152 #define WL_INPUT_METHOD_CONTEXT_LANGUAGE 12
153 #define WL_INPUT_METHOD_CONTEXT_TEXT_DIRECTION 13
156 wl_input_method_context_set_user_data(struct wl_input_method_context *wl_input_method_context, void *user_data)
158 wl_proxy_set_user_data((struct wl_proxy *) wl_input_method_context, user_data);
162 wl_input_method_context_get_user_data(struct wl_input_method_context *wl_input_method_context)
164 return wl_proxy_get_user_data((struct wl_proxy *) wl_input_method_context);
168 wl_input_method_context_destroy(struct wl_input_method_context *wl_input_method_context)
170 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
171 WL_INPUT_METHOD_CONTEXT_DESTROY);
173 wl_proxy_destroy((struct wl_proxy *) wl_input_method_context);
177 wl_input_method_context_commit_string(struct wl_input_method_context *wl_input_method_context, uint32_t serial, const char *text)
179 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
180 WL_INPUT_METHOD_CONTEXT_COMMIT_STRING, serial, text);
184 wl_input_method_context_preedit_string(struct wl_input_method_context *wl_input_method_context, uint32_t serial, const char *text, const char *commit)
186 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
187 WL_INPUT_METHOD_CONTEXT_PREEDIT_STRING, serial, text, commit);
191 wl_input_method_context_preedit_styling(struct wl_input_method_context *wl_input_method_context, uint32_t index, uint32_t length, uint32_t style)
193 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
194 WL_INPUT_METHOD_CONTEXT_PREEDIT_STYLING, index, length, style);
198 wl_input_method_context_preedit_cursor(struct wl_input_method_context *wl_input_method_context, int32_t index)
200 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
201 WL_INPUT_METHOD_CONTEXT_PREEDIT_CURSOR, index);
205 wl_input_method_context_delete_surrounding_text(struct wl_input_method_context *wl_input_method_context, int32_t index, uint32_t length)
207 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
208 WL_INPUT_METHOD_CONTEXT_DELETE_SURROUNDING_TEXT, index, length);
212 wl_input_method_context_cursor_position(struct wl_input_method_context *wl_input_method_context, int32_t index, int32_t anchor)
214 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
215 WL_INPUT_METHOD_CONTEXT_CURSOR_POSITION, index, anchor);
219 wl_input_method_context_modifiers_map(struct wl_input_method_context *wl_input_method_context, struct wl_array *map)
221 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
222 WL_INPUT_METHOD_CONTEXT_MODIFIERS_MAP, map);
226 wl_input_method_context_keysym(struct wl_input_method_context *wl_input_method_context, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers)
228 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
229 WL_INPUT_METHOD_CONTEXT_KEYSYM, serial, time, sym, state, modifiers);
232 static inline struct wl_keyboard *
233 wl_input_method_context_grab_keyboard(struct wl_input_method_context *wl_input_method_context)
235 struct wl_proxy *keyboard;
237 keyboard = wl_proxy_create((struct wl_proxy *) wl_input_method_context,
238 &wl_keyboard_interface);
242 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
243 WL_INPUT_METHOD_CONTEXT_GRAB_KEYBOARD, keyboard);
245 return (struct wl_keyboard *) keyboard;
249 wl_input_method_context_key(struct wl_input_method_context *wl_input_method_context, uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
251 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
252 WL_INPUT_METHOD_CONTEXT_KEY, serial, time, key, state);
256 wl_input_method_context_modifiers(struct wl_input_method_context *wl_input_method_context, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group)
258 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
259 WL_INPUT_METHOD_CONTEXT_MODIFIERS, serial, mods_depressed, mods_latched, mods_locked, group);
263 wl_input_method_context_language(struct wl_input_method_context *wl_input_method_context, uint32_t serial, const char *language)
265 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
266 WL_INPUT_METHOD_CONTEXT_LANGUAGE, serial, language);
270 wl_input_method_context_text_direction(struct wl_input_method_context *wl_input_method_context, uint32_t serial, uint32_t direction)
272 wl_proxy_marshal((struct wl_proxy *) wl_input_method_context,
273 WL_INPUT_METHOD_CONTEXT_TEXT_DIRECTION, serial, direction);
277 * wl_input_method - input method
278 * @activate: activate event
279 * @deactivate: activate event
281 * An input method object is responsible to compose text in response to
282 * input from hardware or virtual keyboards. There is one input method
283 * object per seat. On activate there is a new input method context object
284 * created which allows the input method to communicate with the text
287 struct wl_input_method_listener {
289 * activate - activate event
292 * A text model was activated. Creates an input method context
293 * object which allows communication with the text model.
295 void (*activate)(void *data,
296 struct wl_input_method *wl_input_method,
297 struct wl_input_method_context *id);
299 * deactivate - activate event
302 * The text model corresponding to the context argument was
303 * deactivated. The input method context should be destroyed after
304 * deactivation is handled.
306 void (*deactivate)(void *data,
307 struct wl_input_method *wl_input_method,
308 struct wl_input_method_context *context);
312 wl_input_method_add_listener(struct wl_input_method *wl_input_method,
313 const struct wl_input_method_listener *listener, void *data)
315 return wl_proxy_add_listener((struct wl_proxy *) wl_input_method,
316 (void (**)(void)) listener, data);
320 wl_input_method_set_user_data(struct wl_input_method *wl_input_method, void *user_data)
322 wl_proxy_set_user_data((struct wl_proxy *) wl_input_method, user_data);
326 wl_input_method_get_user_data(struct wl_input_method *wl_input_method)
328 return wl_proxy_get_user_data((struct wl_proxy *) wl_input_method);
332 wl_input_method_destroy(struct wl_input_method *wl_input_method)
334 wl_proxy_destroy((struct wl_proxy *) wl_input_method);
337 #define WL_INPUT_PANEL_GET_INPUT_PANEL_SURFACE 0
340 wl_input_panel_set_user_data(struct wl_input_panel *wl_input_panel, void *user_data)
342 wl_proxy_set_user_data((struct wl_proxy *) wl_input_panel, user_data);
346 wl_input_panel_get_user_data(struct wl_input_panel *wl_input_panel)
348 return wl_proxy_get_user_data((struct wl_proxy *) wl_input_panel);
352 wl_input_panel_destroy(struct wl_input_panel *wl_input_panel)
354 wl_proxy_destroy((struct wl_proxy *) wl_input_panel);
357 static inline struct wl_input_panel_surface *
358 wl_input_panel_get_input_panel_surface(struct wl_input_panel *wl_input_panel, struct wl_surface *surface)
362 id = wl_proxy_create((struct wl_proxy *) wl_input_panel,
363 &wl_input_panel_surface_interface);
367 wl_proxy_marshal((struct wl_proxy *) wl_input_panel,
368 WL_INPUT_PANEL_GET_INPUT_PANEL_SURFACE, id, surface);
370 return (struct wl_input_panel_surface *) id;
373 #ifndef WL_INPUT_PANEL_SURFACE_POSITION_ENUM
374 #define WL_INPUT_PANEL_SURFACE_POSITION_ENUM
375 enum wl_input_panel_surface_position {
376 WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM = 0,
378 #endif /* WL_INPUT_PANEL_SURFACE_POSITION_ENUM */
380 struct wl_input_panel_surface_listener {
382 * cursor_rectangle - cursor rectangle
388 * Notify when the cursor rectangle relative to the input panel
391 void (*cursor_rectangle)(void *data,
392 struct wl_input_panel_surface *wl_input_panel_surface,
400 wl_input_panel_surface_add_listener(struct wl_input_panel_surface *wl_input_panel_surface,
401 const struct wl_input_panel_surface_listener *listener, void *data)
403 return wl_proxy_add_listener((struct wl_proxy *) wl_input_panel_surface,
404 (void (**)(void)) listener, data);
407 #define WL_INPUT_PANEL_SURFACE_SET_TOPLEVEL 0
408 #define WL_INPUT_PANEL_SURFACE_SET_OVERLAY_PANEL 1
411 wl_input_panel_surface_set_user_data(struct wl_input_panel_surface *wl_input_panel_surface, void *user_data)
413 wl_proxy_set_user_data((struct wl_proxy *) wl_input_panel_surface, user_data);
417 wl_input_panel_surface_get_user_data(struct wl_input_panel_surface *wl_input_panel_surface)
419 return wl_proxy_get_user_data((struct wl_proxy *) wl_input_panel_surface);
423 wl_input_panel_surface_destroy(struct wl_input_panel_surface *wl_input_panel_surface)
425 wl_proxy_destroy((struct wl_proxy *) wl_input_panel_surface);
429 wl_input_panel_surface_set_toplevel(struct wl_input_panel_surface *wl_input_panel_surface, struct wl_output *output, uint32_t position)
431 wl_proxy_marshal((struct wl_proxy *) wl_input_panel_surface,
432 WL_INPUT_PANEL_SURFACE_SET_TOPLEVEL, output, position);
436 wl_input_panel_surface_set_overlay_panel(struct wl_input_panel_surface *wl_input_panel_surface)
438 wl_proxy_marshal((struct wl_proxy *) wl_input_panel_surface,
439 WL_INPUT_PANEL_SURFACE_SET_OVERLAY_PANEL);