[PATCH weston 05/10] Use input method protocol from wayland-protocols
Jan Arne Petersen
janarne at gmail.com
Wed Nov 4 05:22:52 PST 2015
On 04/11/15 09:49, Jonas Ådahl wrote:
> Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
Reviewed-by: Jan Arne Petersen <janarne at gmail.com>
> ---
> Makefile.am | 17 ++-
> clients/keyboard.c | 174 +++++++++++++-------------
> clients/weston-simple-im.c | 122 +++++++++----------
> desktop-shell/input-panel.c | 12 +-
> ivi-shell/input-panel-ivi.c | 12 +-
> protocol/input-method.xml | 291 --------------------------------------------
> src/text-backend.c | 26 ++--
> 7 files changed, 186 insertions(+), 468 deletions(-)
> delete mode 100644 protocol/input-method.xml
>
> diff --git a/Makefile.am b/Makefile.am
> index e14878e..6b2b3da 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -119,8 +119,8 @@ nodist_weston_SOURCES = \
> protocol/text-cursor-position-server-protocol.h \
> protocol/text-input-unstable-v1-protocol.c \
> protocol/text-input-unstable-v1-server-protocol.h \
> - protocol/input-method-protocol.c \
> - protocol/input-method-server-protocol.h \
> + protocol/input-method-unstable-v1-protocol.c \
> + protocol/input-method-unstable-v1-server-protocol.h \
> protocol/workspaces-protocol.c \
> protocol/workspaces-server-protocol.h \
> protocol/presentation-timing-unstable-v1-protocol.c \
> @@ -696,15 +696,15 @@ weston_keyboard_SOURCES = clients/keyboard.c
> nodist_weston_keyboard_SOURCES = \
> protocol/desktop-shell-client-protocol.h \
> protocol/desktop-shell-protocol.c \
> - protocol/input-method-protocol.c \
> - protocol/input-method-client-protocol.h
> + protocol/input-method-unstable-v1-protocol.c \
> + protocol/input-method-unstable-v1-client-protocol.h
> weston_keyboard_LDADD = libtoytoolkit.la
> weston_keyboard_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
>
> weston_simple_im_SOURCES = clients/weston-simple-im.c
> nodist_weston_simple_im_SOURCES = \
> - protocol/input-method-protocol.c \
> - protocol/input-method-client-protocol.h
> + protocol/input-method-unstable-v1-protocol.c \
> + protocol/input-method-unstable-v1-client-protocol.h
> weston_simple_im_LDADD = $(CLIENT_LIBS)
> weston_simple_im_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS)
>
> @@ -755,8 +755,8 @@ BUILT_SOURCES += \
> protocol/text-cursor-position-protocol.c \
> protocol/text-input-unstable-v1-protocol.c \
> protocol/text-input-unstable-v1-client-protocol.h \
> - protocol/input-method-protocol.c \
> - protocol/input-method-client-protocol.h \
> + protocol/input-method-unstable-v1-protocol.c \
> + protocol/input-method-unstable-v1-client-protocol.h \
> protocol/desktop-shell-client-protocol.h \
> protocol/desktop-shell-protocol.c \
> protocol/scaler-client-protocol.h \
> @@ -1342,7 +1342,6 @@ BUILT_SOURCES += \
> EXTRA_DIST += \
> protocol/desktop-shell.xml \
> protocol/screenshooter.xml \
> - protocol/input-method.xml \
> protocol/workspaces.xml \
> protocol/text-cursor-position.xml \
> protocol/weston-test.xml \
> diff --git a/clients/keyboard.c b/clients/keyboard.c
> index 61cfda5..b524423 100644
> --- a/clients/keyboard.c
> +++ b/clients/keyboard.c
> @@ -32,15 +32,15 @@
> #include <cairo.h>
>
> #include "window.h"
> -#include "input-method-client-protocol.h"
> +#include "input-method-unstable-v1-client-protocol.h"
> #include "text-input-unstable-v1-client-protocol.h"
>
> struct keyboard;
>
> struct virtual_keyboard {
> - struct wl_input_panel *input_panel;
> - struct wl_input_method *input_method;
> - struct wl_input_method_context *context;
> + struct zwl_input_panel1 *input_panel;
> + struct zwl_input_method1 *input_method;
> + struct zwl_input_method_context1 *context;
> struct display *display;
> struct output *output;
> char *preedit_string;
> @@ -427,11 +427,11 @@ virtual_keyboard_commit_preedit(struct virtual_keyboard *keyboard)
> strlen(keyboard->preedit_string) == 0)
> return;
>
> - wl_input_method_context_cursor_position(keyboard->context,
> - 0, 0);
> - wl_input_method_context_commit_string(keyboard->context,
> - keyboard->serial,
> - keyboard->preedit_string);
> + zwl_input_method_context1_cursor_position(keyboard->context,
> + 0, 0);
> + zwl_input_method_context1_commit_string(keyboard->context,
> + keyboard->serial,
> + keyboard->preedit_string);
>
> if (keyboard->surrounding_text) {
> surrounding_text = insert_text(keyboard->surrounding_text,
> @@ -456,18 +456,18 @@ virtual_keyboard_send_preedit(struct virtual_keyboard *keyboard,
> uint32_t index = strlen(keyboard->preedit_string);
>
> if (keyboard->preedit_style)
> - wl_input_method_context_preedit_styling(keyboard->context,
> - 0,
> - strlen(keyboard->preedit_string),
> - keyboard->preedit_style);
> + zwl_input_method_context1_preedit_styling(keyboard->context,
> + 0,
> + strlen(keyboard->preedit_string),
> + keyboard->preedit_style);
> if (cursor > 0)
> index = cursor;
> - wl_input_method_context_preedit_cursor(keyboard->context,
> - index);
> - wl_input_method_context_preedit_string(keyboard->context,
> - keyboard->serial,
> - keyboard->preedit_string,
> - keyboard->preedit_string);
> + zwl_input_method_context1_preedit_cursor(keyboard->context,
> + index);
> + zwl_input_method_context1_preedit_string(keyboard->context,
> + keyboard->serial,
> + keyboard->preedit_string,
> + keyboard->preedit_string);
> }
>
> static const char *
> @@ -499,12 +499,12 @@ delete_before_cursor(struct virtual_keyboard *keyboard)
>
> end = keyboard->surrounding_text + keyboard->surrounding_cursor;
>
> - wl_input_method_context_delete_surrounding_text(keyboard->context,
> - (start - keyboard->surrounding_text) - keyboard->surrounding_cursor,
> - end - start);
> - wl_input_method_context_commit_string(keyboard->context,
> - keyboard->serial,
> - "");
> + zwl_input_method_context1_delete_surrounding_text(keyboard->context,
> + (start - keyboard->surrounding_text) - keyboard->surrounding_cursor,
> + end - start);
> + zwl_input_method_context1_commit_string(keyboard->context,
> + keyboard->serial,
> + "");
>
> /* Update surrounding text */
> keyboard->surrounding_cursor = start - keyboard->surrounding_text;
> @@ -571,10 +571,10 @@ keyboard_handle_key(struct keyboard *keyboard, uint32_t time, const struct key *
> break;
> case keytype_enter:
> virtual_keyboard_commit_preedit(keyboard->keyboard);
> - wl_input_method_context_keysym(keyboard->keyboard->context,
> - display_get_serial(keyboard->keyboard->display),
> - time,
> - XKB_KEY_Return, key_state, mod_mask);
> + zwl_input_method_context1_keysym(keyboard->keyboard->context,
> + display_get_serial(keyboard->keyboard->display),
> + time,
> + XKB_KEY_Return, key_state, mod_mask);
> break;
> case keytype_space:
> if (state != WL_POINTER_BUTTON_STATE_PRESSED)
> @@ -615,38 +615,38 @@ keyboard_handle_key(struct keyboard *keyboard, uint32_t time, const struct key *
> break;
> case keytype_tab:
> virtual_keyboard_commit_preedit(keyboard->keyboard);
> - wl_input_method_context_keysym(keyboard->keyboard->context,
> - display_get_serial(keyboard->keyboard->display),
> - time,
> - XKB_KEY_Tab, key_state, mod_mask);
> + zwl_input_method_context1_keysym(keyboard->keyboard->context,
> + display_get_serial(keyboard->keyboard->display),
> + time,
> + XKB_KEY_Tab, key_state, mod_mask);
> break;
> case keytype_arrow_up:
> virtual_keyboard_commit_preedit(keyboard->keyboard);
> - wl_input_method_context_keysym(keyboard->keyboard->context,
> - display_get_serial(keyboard->keyboard->display),
> - time,
> - XKB_KEY_Up, key_state, mod_mask);
> + zwl_input_method_context1_keysym(keyboard->keyboard->context,
> + display_get_serial(keyboard->keyboard->display),
> + time,
> + XKB_KEY_Up, key_state, mod_mask);
> break;
> case keytype_arrow_left:
> virtual_keyboard_commit_preedit(keyboard->keyboard);
> - wl_input_method_context_keysym(keyboard->keyboard->context,
> - display_get_serial(keyboard->keyboard->display),
> - time,
> - XKB_KEY_Left, key_state, mod_mask);
> + zwl_input_method_context1_keysym(keyboard->keyboard->context,
> + display_get_serial(keyboard->keyboard->display),
> + time,
> + XKB_KEY_Left, key_state, mod_mask);
> break;
> case keytype_arrow_right:
> virtual_keyboard_commit_preedit(keyboard->keyboard);
> - wl_input_method_context_keysym(keyboard->keyboard->context,
> - display_get_serial(keyboard->keyboard->display),
> - time,
> - XKB_KEY_Right, key_state, mod_mask);
> + zwl_input_method_context1_keysym(keyboard->keyboard->context,
> + display_get_serial(keyboard->keyboard->display),
> + time,
> + XKB_KEY_Right, key_state, mod_mask);
> break;
> case keytype_arrow_down:
> virtual_keyboard_commit_preedit(keyboard->keyboard);
> - wl_input_method_context_keysym(keyboard->keyboard->context,
> - display_get_serial(keyboard->keyboard->display),
> - time,
> - XKB_KEY_Down, key_state, mod_mask);
> + zwl_input_method_context1_keysym(keyboard->keyboard->context,
> + display_get_serial(keyboard->keyboard->display),
> + time,
> + XKB_KEY_Down, key_state, mod_mask);
> break;
> case keytype_style:
> if (state != WL_POINTER_BUTTON_STATE_PRESSED)
> @@ -750,7 +750,7 @@ touch_up_handler(struct widget *widget, struct input *input,
>
> static void
> handle_surrounding_text(void *data,
> - struct wl_input_method_context *context,
> + struct zwl_input_method_context1 *context,
> const char *text,
> uint32_t cursor,
> uint32_t anchor)
> @@ -765,7 +765,7 @@ handle_surrounding_text(void *data,
>
> static void
> handle_reset(void *data,
> - struct wl_input_method_context *context)
> + struct zwl_input_method_context1 *context)
> {
> struct virtual_keyboard *keyboard = data;
>
> @@ -779,7 +779,7 @@ handle_reset(void *data,
>
> static void
> handle_content_type(void *data,
> - struct wl_input_method_context *context,
> + struct zwl_input_method_context1 *context,
> uint32_t hint,
> uint32_t purpose)
> {
> @@ -791,7 +791,7 @@ handle_content_type(void *data,
>
> static void
> handle_invoke_action(void *data,
> - struct wl_input_method_context *context,
> + struct zwl_input_method_context1 *context,
> uint32_t button,
> uint32_t index)
> {
> @@ -805,7 +805,7 @@ handle_invoke_action(void *data,
>
> static void
> handle_commit_state(void *data,
> - struct wl_input_method_context *context,
> + struct zwl_input_method_context1 *context,
> uint32_t serial)
> {
> struct virtual_keyboard *keyboard = data;
> @@ -822,15 +822,19 @@ handle_commit_state(void *data,
> layout->columns * key_width,
> layout->rows * key_height);
>
> - wl_input_method_context_language(context, keyboard->serial, layout->language);
> - wl_input_method_context_text_direction(context, keyboard->serial, layout->text_direction);
> + zwl_input_method_context1_language(context,
> + keyboard->serial,
> + layout->language);
> + zwl_input_method_context1_text_direction(context,
> + keyboard->serial,
> + layout->text_direction);
>
> widget_schedule_redraw(keyboard->keyboard->widget);
> }
>
> static void
> handle_preferred_language(void *data,
> - struct wl_input_method_context *context,
> + struct zwl_input_method_context1 *context,
> const char *language)
> {
> struct virtual_keyboard *keyboard = data;
> @@ -844,7 +848,7 @@ handle_preferred_language(void *data,
> keyboard->preferred_language = strdup(language);
> }
>
> -static const struct wl_input_method_context_listener input_method_context_listener = {
> +static const struct zwl_input_method_context1_listener input_method_context_listener = {
> handle_surrounding_text,
> handle_reset,
> handle_content_type,
> @@ -855,8 +859,8 @@ static const struct wl_input_method_context_listener input_method_context_listen
>
> static void
> input_method_activate(void *data,
> - struct wl_input_method *input_method,
> - struct wl_input_method_context *context)
> + struct zwl_input_method1 *input_method,
> + struct zwl_input_method_context1 *context)
> {
> struct virtual_keyboard *keyboard = data;
> struct wl_array modifiers_map;
> @@ -865,7 +869,7 @@ input_method_activate(void *data,
> keyboard->keyboard->state = KEYBOARD_STATE_DEFAULT;
>
> if (keyboard->context)
> - wl_input_method_context_destroy(keyboard->context);
> + zwl_input_method_context1_destroy(keyboard->context);
>
> if (keyboard->preedit_string)
> free(keyboard->preedit_string);
> @@ -881,15 +885,15 @@ input_method_activate(void *data,
> keyboard->serial = 0;
>
> keyboard->context = context;
> - wl_input_method_context_add_listener(context,
> - &input_method_context_listener,
> - keyboard);
> + zwl_input_method_context1_add_listener(context,
> + &input_method_context_listener,
> + keyboard);
>
> wl_array_init(&modifiers_map);
> keysym_modifiers_add(&modifiers_map, "Shift");
> keysym_modifiers_add(&modifiers_map, "Control");
> keysym_modifiers_add(&modifiers_map, "Mod1");
> - wl_input_method_context_modifiers_map(context, &modifiers_map);
> + zwl_input_method_context1_modifiers_map(context, &modifiers_map);
> keyboard->keysym.shift_mask = keysym_modifiers_get_mask(&modifiers_map, "Shift");
> wl_array_release(&modifiers_map);
>
> @@ -899,27 +903,31 @@ input_method_activate(void *data,
> layout->columns * key_width,
> layout->rows * key_height);
>
> - wl_input_method_context_language(context, keyboard->serial, layout->language);
> - wl_input_method_context_text_direction(context, keyboard->serial, layout->text_direction);
> + zwl_input_method_context1_language(context,
> + keyboard->serial,
> + layout->language);
> + zwl_input_method_context1_text_direction(context,
> + keyboard->serial,
> + layout->text_direction);
>
> widget_schedule_redraw(keyboard->keyboard->widget);
> }
>
> static void
> input_method_deactivate(void *data,
> - struct wl_input_method *input_method,
> - struct wl_input_method_context *context)
> + struct zwl_input_method1 *input_method,
> + struct zwl_input_method_context1 *context)
> {
> struct virtual_keyboard *keyboard = data;
>
> if (!keyboard->context)
> return;
>
> - wl_input_method_context_destroy(keyboard->context);
> + zwl_input_method_context1_destroy(keyboard->context);
> keyboard->context = NULL;
> }
>
> -static const struct wl_input_method_listener input_method_listener = {
> +static const struct zwl_input_method1_listener input_method_listener = {
> input_method_activate,
> input_method_deactivate
> };
> @@ -930,14 +938,16 @@ global_handler(struct display *display, uint32_t name,
> {
> struct virtual_keyboard *keyboard = data;
>
> - if (!strcmp(interface, "wl_input_panel")) {
> + if (!strcmp(interface, "zwl_input_panel1")) {
> keyboard->input_panel =
> - display_bind(display, name, &wl_input_panel_interface, 1);
> - } else if (!strcmp(interface, "wl_input_method")) {
> + display_bind(display, name, &zwl_input_panel1_interface, 1);
> + } else if (!strcmp(interface, "zwl_input_method1")) {
> keyboard->input_method =
> display_bind(display, name,
> - &wl_input_method_interface, 1);
> - wl_input_method_add_listener(keyboard->input_method, &input_method_listener, keyboard);
> + &zwl_input_method1_interface, 1);
> + zwl_input_method1_add_listener(keyboard->input_method,
> + &input_method_listener,
> + keyboard);
> }
> }
>
> @@ -946,7 +956,7 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
> {
> struct keyboard *keyboard;
> const struct layout *layout;
> - struct wl_input_panel_surface *ips;
> + struct zwl_input_panel_surface1 *ips;
>
> layout = get_current_layout(virtual_keyboard);
>
> @@ -971,12 +981,12 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
> layout->rows * key_height);
>
>
> - ips = wl_input_panel_get_input_panel_surface(virtual_keyboard->input_panel,
> - window_get_wl_surface(keyboard->window));
> + ips = zwl_input_panel1_get_input_panel_surface(virtual_keyboard->input_panel,
> + window_get_wl_surface(keyboard->window));
>
> - wl_input_panel_surface_set_toplevel(ips,
> - output_get_wl_output(output),
> - WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
> + zwl_input_panel_surface1_set_toplevel(ips,
> + output_get_wl_output(output),
> + ZWL_INPUT_PANEL_SURFACE1_POSITION_CENTER_BOTTOM);
> }
>
> int
> diff --git a/clients/weston-simple-im.c b/clients/weston-simple-im.c
> index 0e68d48..304ba6e 100644
> --- a/clients/weston-simple-im.c
> +++ b/clients/weston-simple-im.c
> @@ -33,7 +33,7 @@
> #include <linux/input.h>
>
> #include "window.h"
> -#include "input-method-client-protocol.h"
> +#include "input-method-unstable-v1-client-protocol.h"
>
> enum compose_state {
> state_normal,
> @@ -54,8 +54,8 @@ typedef void (*keyboard_input_key_handler_t)(struct simple_im *keyboard,
> enum wl_keyboard_key_state state);
>
> struct simple_im {
> - struct wl_input_method *input_method;
> - struct wl_input_method_context *context;
> + struct zwl_input_method1 *input_method;
> + struct zwl_input_method_context1 *context;
> struct wl_display *display;
> struct wl_registry *registry;
> struct wl_keyboard *keyboard;
> @@ -105,7 +105,7 @@ static const uint32_t ignore_keys_on_compose[] = {
>
> static void
> handle_surrounding_text(void *data,
> - struct wl_input_method_context *context,
> + struct zwl_input_method_context1 *context,
> const char *text,
> uint32_t cursor,
> uint32_t anchor)
> @@ -115,7 +115,7 @@ handle_surrounding_text(void *data,
>
> static void
> handle_reset(void *data,
> - struct wl_input_method_context *context)
> + struct zwl_input_method_context1 *context)
> {
> struct simple_im *keyboard = data;
>
> @@ -126,7 +126,7 @@ handle_reset(void *data,
>
> static void
> handle_content_type(void *data,
> - struct wl_input_method_context *context,
> + struct zwl_input_method_context1 *context,
> uint32_t hint,
> uint32_t purpose)
> {
> @@ -134,7 +134,7 @@ handle_content_type(void *data,
>
> static void
> handle_invoke_action(void *data,
> - struct wl_input_method_context *context,
> + struct zwl_input_method_context1 *context,
> uint32_t button,
> uint32_t index)
> {
> @@ -142,7 +142,7 @@ handle_invoke_action(void *data,
>
> static void
> handle_commit_state(void *data,
> - struct wl_input_method_context *context,
> + struct zwl_input_method_context1 *context,
> uint32_t serial)
> {
> struct simple_im *keyboard = data;
> @@ -152,12 +152,12 @@ handle_commit_state(void *data,
>
> static void
> handle_preferred_language(void *data,
> - struct wl_input_method_context *context,
> + struct zwl_input_method_context1 *context,
> const char *language)
> {
> }
>
> -static const struct wl_input_method_context_listener input_method_context_listener = {
> +static const struct zwl_input_method_context1_listener input_method_context_listener = {
> handle_surrounding_text,
> handle_reset,
> handle_content_type,
> @@ -256,7 +256,7 @@ input_method_keyboard_modifiers(void *data,
> uint32_t group)
> {
> struct simple_im *keyboard = data;
> - struct wl_input_method_context *context = keyboard->context;
> + struct zwl_input_method_context1 *context = keyboard->context;
> xkb_mod_mask_t mask;
>
> xkb_state_update_mask(keyboard->state, mods_depressed,
> @@ -273,9 +273,9 @@ input_method_keyboard_modifiers(void *data,
> if (mask & keyboard->shift_mask)
> keyboard->modifiers |= MOD_SHIFT_MASK;
>
> - wl_input_method_context_modifiers(context, serial,
> - mods_depressed, mods_depressed,
> - mods_latched, group);
> + zwl_input_method_context1_modifiers(context, serial,
> + mods_depressed, mods_depressed,
> + mods_latched, group);
> }
>
> static const struct wl_keyboard_listener input_method_keyboard_listener = {
> @@ -288,23 +288,23 @@ static const struct wl_keyboard_listener input_method_keyboard_listener = {
>
> static void
> input_method_activate(void *data,
> - struct wl_input_method *input_method,
> - struct wl_input_method_context *context)
> + struct zwl_input_method1 *input_method,
> + struct zwl_input_method_context1 *context)
> {
> struct simple_im *keyboard = data;
>
> if (keyboard->context)
> - wl_input_method_context_destroy(keyboard->context);
> + zwl_input_method_context1_destroy(keyboard->context);
>
> keyboard->compose_state = state_normal;
>
> keyboard->serial = 0;
>
> keyboard->context = context;
> - wl_input_method_context_add_listener(context,
> + zwl_input_method_context1_add_listener(context,
> &input_method_context_listener,
> keyboard);
> - keyboard->keyboard = wl_input_method_context_grab_keyboard(context);
> + keyboard->keyboard = zwl_input_method_context1_grab_keyboard(context);
> wl_keyboard_add_listener(keyboard->keyboard,
> &input_method_keyboard_listener,
> keyboard);
> @@ -312,19 +312,19 @@ input_method_activate(void *data,
>
> static void
> input_method_deactivate(void *data,
> - struct wl_input_method *input_method,
> - struct wl_input_method_context *context)
> + struct zwl_input_method1 *input_method,
> + struct zwl_input_method_context1 *context)
> {
> struct simple_im *keyboard = data;
>
> if (!keyboard->context)
> return;
>
> - wl_input_method_context_destroy(keyboard->context);
> + zwl_input_method_context1_destroy(keyboard->context);
> keyboard->context = NULL;
> }
>
> -static const struct wl_input_method_listener input_method_listener = {
> +static const struct zwl_input_method1_listener input_method_listener = {
> input_method_activate,
> input_method_deactivate
> };
> @@ -335,12 +335,12 @@ registry_handle_global(void *data, struct wl_registry *registry,
> {
> struct simple_im *keyboard = data;
>
> - if (!strcmp(interface, "wl_input_method")) {
> + if (!strcmp(interface, "zwl_input_method1")) {
> keyboard->input_method =
> wl_registry_bind(registry, name,
> - &wl_input_method_interface, 1);
> - wl_input_method_add_listener(keyboard->input_method,
> - &input_method_listener, keyboard);
> + &zwl_input_method1_interface, 1);
> + zwl_input_method1_add_listener(keyboard->input_method,
> + &input_method_listener, keyboard);
> }
> }
>
> @@ -379,7 +379,7 @@ simple_im_key_handler(struct simple_im *keyboard,
> uint32_t serial, uint32_t time, uint32_t key, uint32_t sym,
> enum wl_keyboard_key_state state)
> {
> - struct wl_input_method_context *context = keyboard->context;
> + struct zwl_input_method_context1 *context = keyboard->context;
> char text[64];
>
> if (sym == XKB_KEY_Multi_key &&
> @@ -399,7 +399,7 @@ simple_im_key_handler(struct simple_im *keyboard,
>
> for (i = 0; i < sizeof(ignore_keys_on_compose) / sizeof(ignore_keys_on_compose[0]); i++) {
> if (sym == ignore_keys_on_compose[i]) {
> - wl_input_method_context_key(context, keyboard->serial, time, key, state);
> + zwl_input_method_context1_key(context, keyboard->serial, time, key, state);
> return;
> }
> }
> @@ -414,16 +414,16 @@ simple_im_key_handler(struct simple_im *keyboard,
>
> if (cs) {
> if (cs->keys[i + 1] == 0) {
> - wl_input_method_context_preedit_cursor(keyboard->context,
> - 0);
> - wl_input_method_context_preedit_string(keyboard->context,
> - keyboard->serial,
> - "", "");
> - wl_input_method_context_cursor_position(keyboard->context,
> - 0, 0);
> - wl_input_method_context_commit_string(keyboard->context,
> - keyboard->serial,
> - cs->text);
> + zwl_input_method_context1_preedit_cursor(keyboard->context,
> + 0);
> + zwl_input_method_context1_preedit_string(keyboard->context,
> + keyboard->serial,
> + "", "");
> + zwl_input_method_context1_cursor_position(keyboard->context,
> + 0, 0);
> + zwl_input_method_context1_commit_string(keyboard->context,
> + keyboard->serial,
> + cs->text);
> keyboard->compose_state = state_normal;
> } else {
> uint32_t j = 0, idx = 0;
> @@ -432,12 +432,12 @@ simple_im_key_handler(struct simple_im *keyboard,
> idx += xkb_keysym_to_utf8(cs->keys[j], text + idx, sizeof(text) - idx);
> }
>
> - wl_input_method_context_preedit_cursor(keyboard->context,
> - strlen(text));
> - wl_input_method_context_preedit_string(keyboard->context,
> - keyboard->serial,
> - text,
> - text);
> + zwl_input_method_context1_preedit_cursor(keyboard->context,
> + strlen(text));
> + zwl_input_method_context1_preedit_string(keyboard->context,
> + keyboard->serial,
> + text,
> + text);
> }
> } else {
> uint32_t j = 0, idx = 0;
> @@ -445,34 +445,34 @@ simple_im_key_handler(struct simple_im *keyboard,
> for (; j <= i; j++) {
> idx += xkb_keysym_to_utf8(keyboard->compose_seq.keys[j], text + idx, sizeof(text) - idx);
> }
> - wl_input_method_context_preedit_cursor(keyboard->context,
> - 0);
> - wl_input_method_context_preedit_string(keyboard->context,
> - keyboard->serial,
> - "", "");
> - wl_input_method_context_cursor_position(keyboard->context,
> - 0, 0);
> - wl_input_method_context_commit_string(keyboard->context,
> - keyboard->serial,
> - text);
> + zwl_input_method_context1_preedit_cursor(keyboard->context,
> + 0);
> + zwl_input_method_context1_preedit_string(keyboard->context,
> + keyboard->serial,
> + "", "");
> + zwl_input_method_context1_cursor_position(keyboard->context,
> + 0, 0);
> + zwl_input_method_context1_commit_string(keyboard->context,
> + keyboard->serial,
> + text);
> keyboard->compose_state = state_normal;
> }
> return;
> }
>
> if (xkb_keysym_to_utf8(sym, text, sizeof(text)) <= 0) {
> - wl_input_method_context_key(context, serial, time, key, state);
> + zwl_input_method_context1_key(context, serial, time, key, state);
> return;
> }
>
> if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
> return;
>
> - wl_input_method_context_cursor_position(keyboard->context,
> - 0, 0);
> - wl_input_method_context_commit_string(keyboard->context,
> - keyboard->serial,
> - text);
> + zwl_input_method_context1_cursor_position(keyboard->context,
> + 0, 0);
> + zwl_input_method_context1_commit_string(keyboard->context,
> + keyboard->serial,
> + text);
> }
>
> int
> diff --git a/desktop-shell/input-panel.c b/desktop-shell/input-panel.c
> index 95d6287..f5342aa 100644
> --- a/desktop-shell/input-panel.c
> +++ b/desktop-shell/input-panel.c
> @@ -31,7 +31,7 @@
>
> #include "shell.h"
> #include "desktop-shell-server-protocol.h"
> -#include "input-method-server-protocol.h"
> +#include "input-method-unstable-v1-server-protocol.h"
> #include "shared/helpers.h"
>
> struct input_panel_surface {
> @@ -290,7 +290,7 @@ input_panel_surface_set_overlay_panel(struct wl_client *client,
> input_panel_surface->panel = 1;
> }
>
> -static const struct wl_input_panel_surface_interface input_panel_surface_implementation = {
> +static const struct zwl_input_panel_surface1_interface input_panel_surface_implementation = {
> input_panel_surface_set_toplevel,
> input_panel_surface_set_overlay_panel
> };
> @@ -332,14 +332,14 @@ input_panel_get_input_panel_surface(struct wl_client *client,
>
> ipsurf->resource =
> wl_resource_create(client,
> - &wl_input_panel_surface_interface, 1, id);
> + &zwl_input_panel_surface1_interface, 1, id);
> wl_resource_set_implementation(ipsurf->resource,
> &input_panel_surface_implementation,
> ipsurf,
> destroy_input_panel_surface_resource);
> }
>
> -static const struct wl_input_panel_interface input_panel_implementation = {
> +static const struct zwl_input_panel1_interface input_panel_implementation = {
> input_panel_get_input_panel_surface
> };
>
> @@ -359,7 +359,7 @@ bind_input_panel(struct wl_client *client,
> struct wl_resource *resource;
>
> resource = wl_resource_create(client,
> - &wl_input_panel_interface, 1, id);
> + &zwl_input_panel1_interface, 1, id);
>
> if (shell->input_panel.binding == NULL) {
> wl_resource_set_implementation(resource,
> @@ -398,7 +398,7 @@ input_panel_setup(struct desktop_shell *shell)
> wl_list_init(&shell->input_panel.surfaces);
>
> if (wl_global_create(shell->compositor->wl_display,
> - &wl_input_panel_interface, 1,
> + &zwl_input_panel1_interface, 1,
> shell, bind_input_panel) == NULL)
> return -1;
>
> diff --git a/ivi-shell/input-panel-ivi.c b/ivi-shell/input-panel-ivi.c
> index ecd497e..359bd7f 100644
> --- a/ivi-shell/input-panel-ivi.c
> +++ b/ivi-shell/input-panel-ivi.c
> @@ -32,7 +32,7 @@
> #include <string.h>
>
> #include "ivi-shell.h"
> -#include "input-method-server-protocol.h"
> +#include "input-method-unstable-v1-server-protocol.h"
> #include "ivi-layout-private.h"
> #include "shared/helpers.h"
>
> @@ -282,7 +282,7 @@ input_panel_surface_set_overlay_panel(struct wl_client *client,
> input_panel_surface->panel = 1;
> }
>
> -static const struct wl_input_panel_surface_interface input_panel_surface_implementation = {
> +static const struct zwl_input_panel_surface1_interface input_panel_surface_implementation = {
> input_panel_surface_set_toplevel,
> input_panel_surface_set_overlay_panel
> };
> @@ -324,14 +324,14 @@ input_panel_get_input_panel_surface(struct wl_client *client,
>
> ipsurf->resource =
> wl_resource_create(client,
> - &wl_input_panel_surface_interface, 1, id);
> + &zwl_input_panel_surface1_interface, 1, id);
> wl_resource_set_implementation(ipsurf->resource,
> &input_panel_surface_implementation,
> ipsurf,
> destroy_input_panel_surface_resource);
> }
>
> -static const struct wl_input_panel_interface input_panel_implementation = {
> +static const struct zwl_input_panel1_interface input_panel_implementation = {
> input_panel_get_input_panel_surface
> };
>
> @@ -351,7 +351,7 @@ bind_input_panel(struct wl_client *client,
> struct wl_resource *resource;
>
> resource = wl_resource_create(client,
> - &wl_input_panel_interface, 1, id);
> + &zwl_input_panel1_interface, 1, id);
>
> if (shell->input_panel.binding == NULL) {
> wl_resource_set_implementation(resource,
> @@ -390,7 +390,7 @@ input_panel_setup(struct ivi_shell *shell)
> wl_list_init(&shell->input_panel.surfaces);
>
> if (wl_global_create(shell->compositor->wl_display,
> - &wl_input_panel_interface, 1,
> + &zwl_input_panel1_interface, 1,
> shell, bind_input_panel) == NULL)
> return -1;
>
> diff --git a/protocol/input-method.xml b/protocol/input-method.xml
> deleted file mode 100644
> index 657230c..0000000
> --- a/protocol/input-method.xml
> +++ /dev/null
> @@ -1,291 +0,0 @@
> -<?xml version="1.0" encoding="UTF-8"?>
> -<protocol name="input_method">
> -
> - <copyright>
> - Copyright © 2012, 2013 Intel Corporation
> -
> - Permission is hereby granted, free of charge, to any person obtaining a
> - copy of this software and associated documentation files (the "Software"),
> - to deal in the Software without restriction, including without limitation
> - the rights to use, copy, modify, merge, publish, distribute, sublicense,
> - and/or sell copies of the Software, and to permit persons to whom the
> - Software is furnished to do so, subject to the following conditions:
> -
> - The above copyright notice and this permission notice (including the next
> - paragraph) shall be included in all copies or substantial portions of the
> - Software.
> -
> - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> - DEALINGS IN THE SOFTWARE.
> - </copyright>
> -
> - <interface name="wl_input_method_context" version="1">
> - <description summary="input method context">
> - Corresponds to a text input on input method side. An input method context
> - is created on text input activation on the input method side. It allows to
> - receive information about the text input from the application via events.
> - Input method contexts do not keep state after deactivation and should be
> - destroyed after deactivation is handled.
> -
> - Text is generally UTF-8 encoded, indices and lengths are in bytes.
> -
> - Serials are used to synchronize the state between the text input and
> - an input method. New serials are sent by the text input in the
> - commit_state request and are used by the input method to indicate
> - the known text input state in events like preedit_string, commit_string,
> - and keysym. The text input can then ignore events from the input method
> - which are based on an outdated state (for example after a reset).
> - </description>
> -
> - <request name="destroy" type="destructor"/>
> -
> - <request name="commit_string">
> - <description summary="commit string">
> - Send the commit string text for insertion to the application.
> -
> - The text to commit could be either just a single character after a key
> - press or the result of some composing (pre-edit). It could be also an
> - empty text when some text should be removed (see
> - delete_surrounding_text) or when the input cursor should be moved (see
> - cursor_position).
> -
> - Any previously set composing text will be removed.
> - </description>
> - <arg name="serial" type="uint" summary="serial of the latest known text input state"/>
> - <arg name="text" type="string"/>
> - </request>
> -
> - <request name="preedit_string">
> - <description summary="pre-edit string">
> - Send the pre-edit string text to the application text input.
> -
> - The commit text can be used to replace the preedit text on reset (for
> - example on unfocus).
> -
> - Also previously sent preedit_style and preedit_cursor requests are
> - processed bt the text_input also.
> - </description>
> - <arg name="serial" type="uint" summary="serial of the latest known text input state"/>
> - <arg name="text" type="string"/>
> - <arg name="commit" type="string"/>
> - </request>
> -
> - <request name="preedit_styling">
> - <description summary="pre-edit styling">
> - Sets styling information on composing text. The style is applied for
> - length in bytes from index relative to the beginning of
> - the composing text (as byte offset). Multiple styles can
> - be applied to a composing text.
> -
> - This request should be sent before sending preedit_string request.
> - </description>
> - <arg name="index" type="uint"/>
> - <arg name="length" type="uint"/>
> - <arg name="style" type="uint"/>
> - </request>
> -
> - <request name="preedit_cursor">
> - <description summary="pre-edit cursor">
> - Sets the cursor position inside the composing text (as byte offset)
> - relative to the start of the composing text.
> -
> - When index is negative no cursor should be displayed.
> -
> - This request should be sent before sending preedit_string request.
> - </description>
> - <arg name="index" type="int"/>
> - </request>
> -
> - <request name="delete_surrounding_text">
> - <description summary="delete text">
> - This request will be handled on text_input side as part of a directly
> - following commit_string request.
> - </description>
> - <arg name="index" type="int"/>
> - <arg name="length" type="uint"/>
> - </request>
> -
> - <request name="cursor_position">
> - <description summary="set cursor to a new position">
> - Sets the cursor and anchor to a new position. Index is the new cursor
> - position in bytes (when >= 0 relative to the end of inserted text
> - else relative to beginning of inserted text). Anchor is the new anchor
> - position in bytes (when >= 0 relative to the end of inserted text, else
> - relative to beginning of inserted text). When there should be no
> - selected text anchor should be the same as index.
> -
> - This request will be handled on text_input side as part of a directly
> - following commit_string request.
> - </description>
> - <arg name="index" type="int"/>
> - <arg name="anchor" type="int"/>
> - </request>
> -
> - <request name="modifiers_map">
> - <arg name="map" type="array"/>
> - </request>
> -
> - <request name="keysym">
> - <description summary="keysym">
> - Notify when a key event was sent. Key events should not be used for
> - normal text input operations, which should be done with commit_string,
> - delete_surrounfing_text, etc. The key event follows the wl_keyboard key
> - event convention. Sym is a XKB keysym, state a wl_keyboard key_state.
> - </description>
> - <arg name="serial" type="uint" summary="serial of the latest known text input state"/>
> - <arg name="time" type="uint"/>
> - <arg name="sym" type="uint"/>
> - <arg name="state" type="uint"/>
> - <arg name="modifiers" type="uint"/>
> - </request>
> -
> - <request name="grab_keyboard">
> - <description summary="grab hardware keyboard">
> - Allows an input method to receive hardware keyboard input and process
> - key events to generate text events (with pre-edit) over the wire. This
> - allows input methods which compose multiple key events for inputting
> - text like it is done for CJK languages.
> - </description>
> - <arg name="keyboard" type="new_id" interface="wl_keyboard"/>
> - </request>
> -
> - <request name="key">
> - <description summary="forward key event">
> - Should be used when filtering key events with grab_keyboard.
> -
> - When the wl_keyboard::key event is not processed by the input
> - method itself and should be sent to the client instead, forward it
> - with this request. The arguments should be the ones from the
> - wl_keyboard::key event.
> -
> - For generating custom key events use the keysym request instead.
> - </description>
> - <arg name="serial" type="uint" summary="serial from wl_keyboard::key"/>
> - <arg name="time" type="uint" summary="time from wl_keyboard::key"/>
> - <arg name="key" type="uint" summary="key from wl_keyboard::key"/>
> - <arg name="state" type="uint" summary="state from wl_keyboard::key"/>
> - </request>
> -
> - <request name="modifiers">
> - <description summary="forward modifiers event">
> - Should be used when filtering key events with grab_keyboard.
> -
> - When the wl_keyboard::modifiers event should be also send to the
> - client, forward it with this request. The arguments should be the ones
> - from the wl_keyboard::modifiers event.
> - </description>
> - <arg name="serial" type="uint" summary="serial from wl_keyboard::modifiers"/>
> - <arg name="mods_depressed" type="uint" summary="mods_depressed from wl_keyboard::modifiers"/>
> - <arg name="mods_latched" type="uint" summary="mods_latched from wl_keyboard::modifiers"/>
> - <arg name="mods_locked" type="uint" summary="mods_locked from wl_keyboard::modifiers"/>
> - <arg name="group" type="uint" summary="group from wl_keyboard::modifiers"/>
> - </request>
> -
> - <request name="language">
> - <arg name="serial" type="uint" summary="serial of the latest known text input state"/>
> - <arg name="language" type="string"/>
> - </request>
> - <request name="text_direction">
> - <arg name="serial" type="uint" summary="serial of the latest known text input state"/>
> - <arg name="direction" type="uint"/>
> - </request>
> -
> - <event name="surrounding_text">
> - <description summary="surrounding text event">
> - The plain surrounding text around the input position. Cursor is the
> - position in bytes within the surrounding text relative to the beginning
> - of the text. Anchor is the position in bytes of the selection anchor
> - within the surrounding text relative to the beginning of the text. If
> - there is no selected text anchor is the same as cursor.
> - </description>
> - <arg name="text" type="string"/>
> - <arg name="cursor" type="uint"/>
> - <arg name="anchor" type="uint"/>
> - </event>
> -
> - <event name="reset">
> - </event>
> -
> - <event name="content_type">
> - <arg name="hint" type="uint"/>
> - <arg name="purpose" type="uint"/>
> - </event>
> -
> - <event name="invoke_action">
> - <arg name="button" type="uint"/>
> - <arg name="index" type="uint"/>
> - </event>
> -
> - <event name="commit_state">
> - <arg name="serial" type="uint" summary="serial of text input state"/>
> - </event>
> -
> - <event name="preferred_language">
> - <arg name="language" type="string"/>
> - </event>
> - </interface>
> -
> - <interface name="wl_input_method" version="1">
> - <description summary="input method">
> - An input method object is responsible to compose text in response to
> - input from hardware or virtual keyboards. There is one input method
> - object per seat. On activate there is a new input method context object
> - created which allows the input method to communicate with the text input.
> - </description>
> -
> - <event name="activate">
> - <description summary="activate event">
> - A text input was activated. Creates an input method context object
> - which allows communication with the text input.
> - </description>
> - <arg name="id" type="new_id" interface="wl_input_method_context"/>
> - </event>
> -
> - <event name="deactivate">
> - <description summary="deactivate event">
> - The text input corresponding to the context argument was deactivated.
> - The input method context should be destroyed after deactivation is
> - handled.
> - </description>
> - <arg name="context" type="object" interface="wl_input_method_context"/>
> - </event>
> - </interface>
> -
> - <interface name="wl_input_panel" version="1">
> - <description summary="interface for implementing keyboards">
> - Only one client can bind this interface at a time.
> - </description>
> -
> - <request name="get_input_panel_surface">
> - <arg name="id" type="new_id" interface="wl_input_panel_surface"/>
> - <arg name="surface" type="object" interface="wl_surface"/>
> - </request>
> - </interface>
> -
> - <interface name="wl_input_panel_surface" version="1">
> - <enum name="position">
> - <entry name="center_bottom" value="0"/>
> - </enum>
> -
> - <request name="set_toplevel">
> - <description summary="set the surface type as a keyboard">
> - A keyboard surface is only shown when a text input is active.
> - </description>
> - <arg name="output" type="object" interface="wl_output"/>
> - <arg name="position" type="uint"/>
> - </request>
> -
> - <request name="set_overlay_panel">
> - <description summary="set the surface type as an overlay panel">
> - An overlay panel is shown near the input cursor above the application
> - window when a text input is active.
> - </description>
> - </request>
> - </interface>
> -
> -</protocol>
> diff --git a/src/text-backend.c b/src/text-backend.c
> index 5227b97..9fb5bef 100644
> --- a/src/text-backend.c
> +++ b/src/text-backend.c
> @@ -34,7 +34,7 @@
>
> #include "compositor.h"
> #include "text-input-unstable-v1-server-protocol.h"
> -#include "input-method-server-protocol.h"
> +#include "input-method-unstable-v1-server-protocol.h"
> #include "shared/helpers.h"
>
> struct text_input_manager;
> @@ -127,7 +127,7 @@ deactivate_input_method(struct input_method *input_method)
>
> if (input_method->context && input_method->input_method_binding) {
> input_method_context_end_keyboard_grab(input_method->context);
> - wl_input_method_send_deactivate(
> + zwl_input_method1_send_deactivate(
> input_method->input_method_binding,
> input_method->context->resource);
> }
> @@ -172,7 +172,7 @@ text_input_set_surrounding_text(struct wl_client *client,
> &text_input->input_methods, link) {
> if (!input_method->context)
> continue;
> - wl_input_method_context_send_surrounding_text(
> + zwl_input_method_context1_send_surrounding_text(
> input_method->context->resource, text, cursor, anchor);
> }
> }
> @@ -245,7 +245,7 @@ text_input_reset(struct wl_client *client,
> &text_input->input_methods, link) {
> if (!input_method->context)
> continue;
> - wl_input_method_context_send_reset(
> + zwl_input_method_context1_send_reset(
> input_method->context->resource);
> }
> }
> @@ -283,7 +283,7 @@ text_input_set_content_type(struct wl_client *client,
> &text_input->input_methods, link) {
> if (!input_method->context)
> continue;
> - wl_input_method_context_send_content_type(
> + zwl_input_method_context1_send_content_type(
> input_method->context->resource, hint, purpose);
> }
> }
> @@ -301,7 +301,7 @@ text_input_invoke_action(struct wl_client *client,
> &text_input->input_methods, link) {
> if (!input_method->context)
> continue;
> - wl_input_method_context_send_invoke_action(
> + zwl_input_method_context1_send_invoke_action(
> input_method->context->resource, button, index);
> }
> }
> @@ -318,7 +318,7 @@ text_input_commit_state(struct wl_client *client,
> &text_input->input_methods, link) {
> if (!input_method->context)
> continue;
> - wl_input_method_context_send_commit_state(
> + zwl_input_method_context1_send_commit_state(
> input_method->context->resource, serial);
> }
> }
> @@ -368,7 +368,7 @@ text_input_set_preferred_language(struct wl_client *client,
> &text_input->input_methods, link) {
> if (!input_method->context)
> continue;
> - wl_input_method_context_send_preferred_language(
> + zwl_input_method_context1_send_preferred_language(
> input_method->context->resource, language);
> }
> }
> @@ -745,7 +745,7 @@ input_method_context_text_direction(struct wl_client *client,
> }
>
>
> -static const struct wl_input_method_context_interface context_implementation = {
> +static const struct zwl_input_method_context1_interface context_implementation = {
> input_method_context_destroy,
> input_method_context_commit_string,
> input_method_context_preedit_string,
> @@ -794,7 +794,7 @@ input_method_context_create(struct text_input *input,
> binding = input_method->input_method_binding;
> context->resource =
> wl_resource_create(wl_resource_get_client(binding),
> - &wl_input_method_context_interface, 1, 0);
> + &zwl_input_method_context1_interface, 1, 0);
> wl_resource_set_implementation(context->resource,
> &context_implementation,
> context, destroy_input_method_context);
> @@ -804,7 +804,7 @@ input_method_context_create(struct text_input *input,
> input_method->context = context;
>
>
> - wl_input_method_send_activate(binding, context->resource);
> + zwl_input_method1_send_activate(binding, context->resource);
> }
>
> static void
> @@ -848,7 +848,7 @@ bind_input_method(struct wl_client *client,
> struct wl_resource *resource;
>
> resource =
> - wl_resource_create(client, &wl_input_method_interface, 1, id);
> + wl_resource_create(client, &zwl_input_method1_interface, 1, id);
>
> if (input_method->input_method_binding != NULL) {
> wl_resource_post_error(resource,
> @@ -999,7 +999,7 @@ text_backend_seat_created(struct text_backend *text_backend,
> input_method->text_backend = text_backend;
>
> input_method->input_method_global =
> - wl_global_create(ec->wl_display, &wl_input_method_interface, 1,
> + wl_global_create(ec->wl_display, &zwl_input_method1_interface, 1,
> input_method, bind_input_method);
>
> input_method->destroy_listener.notify = input_method_notifier_destroy;
>
--
Jan Arne Petersen | jan.petersen at kdab.com | Senior Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts
More information about the wayland-devel
mailing list