text: Rename input_method to wl_input_method

Also rename input_method_context to wl_input_method_context,
input_panel to wl_input_panel and input_panel_surface to
wl_input_panel_surface.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
dev
Jan Arne Petersen 12 years ago committed by Kristian Høgsberg
parent 2f51d8a2ff
commit cc75ec11ca
  1. 162
      clients/keyboard.c
  2. 124
      clients/weston-simple-im.c
  3. 14
      protocol/input-method.xml
  4. 12
      src/shell.c
  5. 44
      src/text-backend.c

@ -35,9 +35,9 @@
struct keyboard; struct keyboard;
struct virtual_keyboard { struct virtual_keyboard {
struct input_panel *input_panel; struct wl_input_panel *input_panel;
struct input_method *input_method; struct wl_input_method *input_method;
struct input_method_context *context; struct wl_input_method_context *context;
struct display *display; struct display *display;
struct output *output; struct output *output;
char *preedit_string; char *preedit_string;
@ -387,11 +387,11 @@ virtual_keyboard_commit_preedit(struct virtual_keyboard *keyboard)
strlen(keyboard->preedit_string) == 0) strlen(keyboard->preedit_string) == 0)
return; return;
input_method_context_cursor_position(keyboard->context, wl_input_method_context_cursor_position(keyboard->context,
0, 0); 0, 0);
input_method_context_commit_string(keyboard->context, wl_input_method_context_commit_string(keyboard->context,
keyboard->serial, keyboard->serial,
keyboard->preedit_string); keyboard->preedit_string);
free(keyboard->preedit_string); free(keyboard->preedit_string);
keyboard->preedit_string = strdup(""); keyboard->preedit_string = strdup("");
} }
@ -403,18 +403,18 @@ virtual_keyboard_send_preedit(struct virtual_keyboard *keyboard,
uint32_t index = strlen(keyboard->preedit_string); uint32_t index = strlen(keyboard->preedit_string);
if (keyboard->preedit_style) if (keyboard->preedit_style)
input_method_context_preedit_styling(keyboard->context, wl_input_method_context_preedit_styling(keyboard->context,
0, 0,
strlen(keyboard->preedit_string), strlen(keyboard->preedit_string),
keyboard->preedit_style); keyboard->preedit_style);
if (cursor > 0) if (cursor > 0)
index = cursor; index = cursor;
input_method_context_preedit_cursor(keyboard->context, wl_input_method_context_preedit_cursor(keyboard->context,
index); index);
input_method_context_preedit_string(keyboard->context, wl_input_method_context_preedit_string(keyboard->context,
keyboard->serial, keyboard->serial,
keyboard->preedit_string, keyboard->preedit_string,
keyboard->preedit_string); keyboard->preedit_string);
} }
static void static void
@ -438,11 +438,11 @@ keyboard_handle_key(struct keyboard *keyboard, uint32_t time, const struct key *
break; break;
if (strlen(keyboard->keyboard->preedit_string) == 0) { if (strlen(keyboard->keyboard->preedit_string) == 0) {
input_method_context_delete_surrounding_text(keyboard->keyboard->context, wl_input_method_context_delete_surrounding_text(keyboard->keyboard->context,
-1, 1); -1, 1);
input_method_context_commit_string(keyboard->keyboard->context, wl_input_method_context_commit_string(keyboard->keyboard->context,
keyboard->keyboard->serial, keyboard->keyboard->serial,
""); "");
} else { } else {
keyboard->keyboard->preedit_string[strlen(keyboard->keyboard->preedit_string) - 1] = '\0'; keyboard->keyboard->preedit_string[strlen(keyboard->keyboard->preedit_string) - 1] = '\0';
virtual_keyboard_send_preedit(keyboard->keyboard, -1); virtual_keyboard_send_preedit(keyboard->keyboard, -1);
@ -450,10 +450,10 @@ keyboard_handle_key(struct keyboard *keyboard, uint32_t time, const struct key *
break; break;
case keytype_enter: case keytype_enter:
virtual_keyboard_commit_preedit(keyboard->keyboard); virtual_keyboard_commit_preedit(keyboard->keyboard);
input_method_context_keysym(keyboard->keyboard->context, wl_input_method_context_keysym(keyboard->keyboard->context,
display_get_serial(keyboard->keyboard->display), display_get_serial(keyboard->keyboard->display),
time, time,
XKB_KEY_Return, key_state, mod_mask); XKB_KEY_Return, key_state, mod_mask);
break; break;
case keytype_space: case keytype_space:
if (state != WL_POINTER_BUTTON_STATE_PRESSED) if (state != WL_POINTER_BUTTON_STATE_PRESSED)
@ -476,38 +476,38 @@ keyboard_handle_key(struct keyboard *keyboard, uint32_t time, const struct key *
break; break;
case keytype_tab: case keytype_tab:
virtual_keyboard_commit_preedit(keyboard->keyboard); virtual_keyboard_commit_preedit(keyboard->keyboard);
input_method_context_keysym(keyboard->keyboard->context, wl_input_method_context_keysym(keyboard->keyboard->context,
display_get_serial(keyboard->keyboard->display), display_get_serial(keyboard->keyboard->display),
time, time,
XKB_KEY_Tab, key_state, mod_mask); XKB_KEY_Tab, key_state, mod_mask);
break; break;
case keytype_arrow_up: case keytype_arrow_up:
virtual_keyboard_commit_preedit(keyboard->keyboard); virtual_keyboard_commit_preedit(keyboard->keyboard);
input_method_context_keysym(keyboard->keyboard->context, wl_input_method_context_keysym(keyboard->keyboard->context,
display_get_serial(keyboard->keyboard->display), display_get_serial(keyboard->keyboard->display),
time, time,
XKB_KEY_Up, key_state, mod_mask); XKB_KEY_Up, key_state, mod_mask);
break; break;
case keytype_arrow_left: case keytype_arrow_left:
virtual_keyboard_commit_preedit(keyboard->keyboard); virtual_keyboard_commit_preedit(keyboard->keyboard);
input_method_context_keysym(keyboard->keyboard->context, wl_input_method_context_keysym(keyboard->keyboard->context,
display_get_serial(keyboard->keyboard->display), display_get_serial(keyboard->keyboard->display),
time, time,
XKB_KEY_Left, key_state, mod_mask); XKB_KEY_Left, key_state, mod_mask);
break; break;
case keytype_arrow_right: case keytype_arrow_right:
virtual_keyboard_commit_preedit(keyboard->keyboard); virtual_keyboard_commit_preedit(keyboard->keyboard);
input_method_context_keysym(keyboard->keyboard->context, wl_input_method_context_keysym(keyboard->keyboard->context,
display_get_serial(keyboard->keyboard->display), display_get_serial(keyboard->keyboard->display),
time, time,
XKB_KEY_Right, key_state, mod_mask); XKB_KEY_Right, key_state, mod_mask);
break; break;
case keytype_arrow_down: case keytype_arrow_down:
virtual_keyboard_commit_preedit(keyboard->keyboard); virtual_keyboard_commit_preedit(keyboard->keyboard);
input_method_context_keysym(keyboard->keyboard->context, wl_input_method_context_keysym(keyboard->keyboard->context,
display_get_serial(keyboard->keyboard->display), display_get_serial(keyboard->keyboard->display),
time, time,
XKB_KEY_Down, key_state, mod_mask); XKB_KEY_Down, key_state, mod_mask);
break; break;
case keytype_style: case keytype_style:
if (state != WL_POINTER_BUTTON_STATE_PRESSED) if (state != WL_POINTER_BUTTON_STATE_PRESSED)
@ -558,7 +558,7 @@ button_handler(struct widget *widget,
static void static void
handle_surrounding_text(void *data, handle_surrounding_text(void *data,
struct input_method_context *context, struct wl_input_method_context *context,
const char *text, const char *text,
uint32_t cursor, uint32_t cursor,
uint32_t anchor) uint32_t anchor)
@ -571,7 +571,7 @@ handle_surrounding_text(void *data,
static void static void
handle_reset(void *data, handle_reset(void *data,
struct input_method_context *context) struct wl_input_method_context *context)
{ {
struct virtual_keyboard *keyboard = data; struct virtual_keyboard *keyboard = data;
@ -585,7 +585,7 @@ handle_reset(void *data,
static void static void
handle_content_type(void *data, handle_content_type(void *data,
struct input_method_context *context, struct wl_input_method_context *context,
uint32_t hint, uint32_t hint,
uint32_t purpose) uint32_t purpose)
{ {
@ -597,7 +597,7 @@ handle_content_type(void *data,
static void static void
handle_invoke_action(void *data, handle_invoke_action(void *data,
struct input_method_context *context, struct wl_input_method_context *context,
uint32_t button, uint32_t button,
uint32_t index) uint32_t index)
{ {
@ -611,7 +611,7 @@ handle_invoke_action(void *data,
static void static void
handle_commit_state(void *data, handle_commit_state(void *data,
struct input_method_context *context, struct wl_input_method_context *context,
uint32_t serial) uint32_t serial)
{ {
struct virtual_keyboard *keyboard = data; struct virtual_keyboard *keyboard = data;
@ -628,15 +628,15 @@ handle_commit_state(void *data,
layout->columns * key_width, layout->columns * key_width,
layout->rows * key_height); layout->rows * key_height);
input_method_context_language(context, keyboard->serial, layout->language); wl_input_method_context_language(context, keyboard->serial, layout->language);
input_method_context_text_direction(context, keyboard->serial, layout->text_direction); wl_input_method_context_text_direction(context, keyboard->serial, layout->text_direction);
widget_schedule_redraw(keyboard->keyboard->widget); widget_schedule_redraw(keyboard->keyboard->widget);
} }
static void static void
handle_preferred_language(void *data, handle_preferred_language(void *data,
struct input_method_context *context, struct wl_input_method_context *context,
const char *language) const char *language)
{ {
struct virtual_keyboard *keyboard = data; struct virtual_keyboard *keyboard = data;
@ -650,7 +650,7 @@ handle_preferred_language(void *data,
keyboard->preferred_language = strdup(language); keyboard->preferred_language = strdup(language);
} }
static const struct input_method_context_listener input_method_context_listener = { static const struct wl_input_method_context_listener input_method_context_listener = {
handle_surrounding_text, handle_surrounding_text,
handle_reset, handle_reset,
handle_content_type, handle_content_type,
@ -661,8 +661,8 @@ static const struct input_method_context_listener input_method_context_listener
static void static void
input_method_activate(void *data, input_method_activate(void *data,
struct input_method *input_method, struct wl_input_method *input_method,
struct input_method_context *context) struct wl_input_method_context *context)
{ {
struct virtual_keyboard *keyboard = data; struct virtual_keyboard *keyboard = data;
struct wl_array modifiers_map; struct wl_array modifiers_map;
@ -671,7 +671,7 @@ input_method_activate(void *data,
keyboard->keyboard->state = keyboardstate_default; keyboard->keyboard->state = keyboardstate_default;
if (keyboard->context) if (keyboard->context)
input_method_context_destroy(keyboard->context); wl_input_method_context_destroy(keyboard->context);
if (keyboard->preedit_string) if (keyboard->preedit_string)
free(keyboard->preedit_string); free(keyboard->preedit_string);
@ -687,15 +687,15 @@ input_method_activate(void *data,
keyboard->serial = 0; keyboard->serial = 0;
keyboard->context = context; keyboard->context = context;
input_method_context_add_listener(context, wl_input_method_context_add_listener(context,
&input_method_context_listener, &input_method_context_listener,
keyboard); keyboard);
wl_array_init(&modifiers_map); wl_array_init(&modifiers_map);
keysym_modifiers_add(&modifiers_map, "Shift"); keysym_modifiers_add(&modifiers_map, "Shift");
keysym_modifiers_add(&modifiers_map, "Control"); keysym_modifiers_add(&modifiers_map, "Control");
keysym_modifiers_add(&modifiers_map, "Mod1"); keysym_modifiers_add(&modifiers_map, "Mod1");
input_method_context_modifiers_map(context, &modifiers_map); wl_input_method_context_modifiers_map(context, &modifiers_map);
keyboard->keysym.shift_mask = keysym_modifiers_get_mask(&modifiers_map, "Shift"); keyboard->keysym.shift_mask = keysym_modifiers_get_mask(&modifiers_map, "Shift");
wl_array_release(&modifiers_map); wl_array_release(&modifiers_map);
@ -705,27 +705,27 @@ input_method_activate(void *data,
layout->columns * key_width, layout->columns * key_width,
layout->rows * key_height); layout->rows * key_height);
input_method_context_language(context, keyboard->serial, layout->language); wl_input_method_context_language(context, keyboard->serial, layout->language);
input_method_context_text_direction(context, keyboard->serial, layout->text_direction); wl_input_method_context_text_direction(context, keyboard->serial, layout->text_direction);
widget_schedule_redraw(keyboard->keyboard->widget); widget_schedule_redraw(keyboard->keyboard->widget);
} }
static void static void
input_method_deactivate(void *data, input_method_deactivate(void *data,
struct input_method *input_method, struct wl_input_method *input_method,
struct input_method_context *context) struct wl_input_method_context *context)
{ {
struct virtual_keyboard *keyboard = data; struct virtual_keyboard *keyboard = data;
if (!keyboard->context) if (!keyboard->context)
return; return;
input_method_context_destroy(keyboard->context); wl_input_method_context_destroy(keyboard->context);
keyboard->context = NULL; keyboard->context = NULL;
} }
static const struct input_method_listener input_method_listener = { static const struct wl_input_method_listener input_method_listener = {
input_method_activate, input_method_activate,
input_method_deactivate input_method_deactivate
}; };
@ -736,14 +736,14 @@ global_handler(struct display *display, uint32_t name,
{ {
struct virtual_keyboard *keyboard = data; struct virtual_keyboard *keyboard = data;
if (!strcmp(interface, "input_panel")) { if (!strcmp(interface, "wl_input_panel")) {
keyboard->input_panel = keyboard->input_panel =
display_bind(display, name, &input_panel_interface, 1); display_bind(display, name, &wl_input_panel_interface, 1);
} else if (!strcmp(interface, "input_method")) { } else if (!strcmp(interface, "wl_input_method")) {
keyboard->input_method = keyboard->input_method =
display_bind(display, name, display_bind(display, name,
&input_method_interface, 1); &wl_input_method_interface, 1);
input_method_add_listener(keyboard->input_method, &input_method_listener, keyboard); wl_input_method_add_listener(keyboard->input_method, &input_method_listener, keyboard);
} }
} }
@ -752,8 +752,8 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
{ {
struct keyboard *keyboard; struct keyboard *keyboard;
const struct layout *layout; const struct layout *layout;
struct input_panel_surface *ips; struct wl_input_panel_surface *ips;
layout = get_current_layout(virtual_keyboard); layout = get_current_layout(virtual_keyboard);
keyboard = malloc(sizeof *keyboard); keyboard = malloc(sizeof *keyboard);
@ -777,12 +777,12 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
layout->rows * key_height); layout->rows * key_height);
ips = input_panel_get_input_panel_surface(virtual_keyboard->input_panel, ips = wl_input_panel_get_input_panel_surface(virtual_keyboard->input_panel,
window_get_wl_surface(keyboard->window)); window_get_wl_surface(keyboard->window));
input_panel_surface_set_toplevel(ips, wl_input_panel_surface_set_toplevel(ips,
output_get_wl_output(output), output_get_wl_output(output),
INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM); WL_INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
} }
int int

@ -51,8 +51,8 @@ typedef void (*keyboard_input_key_handler_t)(struct simple_im *keyboard,
enum wl_keyboard_key_state state); enum wl_keyboard_key_state state);
struct simple_im { struct simple_im {
struct input_method *input_method; struct wl_input_method *input_method;
struct input_method_context *context; struct wl_input_method_context *context;
struct wl_display *display; struct wl_display *display;
struct wl_registry *registry; struct wl_registry *registry;
struct wl_keyboard *keyboard; struct wl_keyboard *keyboard;
@ -102,7 +102,7 @@ static const uint32_t ignore_keys_on_compose[] = {
static void static void
handle_surrounding_text(void *data, handle_surrounding_text(void *data,
struct input_method_context *context, struct wl_input_method_context *context,
const char *text, const char *text,
uint32_t cursor, uint32_t cursor,
uint32_t anchor) uint32_t anchor)
@ -112,7 +112,7 @@ handle_surrounding_text(void *data,
static void static void
handle_reset(void *data, handle_reset(void *data,
struct input_method_context *context) struct wl_input_method_context *context)
{ {
struct simple_im *keyboard = data; struct simple_im *keyboard = data;
@ -123,7 +123,7 @@ handle_reset(void *data,
static void static void
handle_content_type(void *data, handle_content_type(void *data,
struct input_method_context *context, struct wl_input_method_context *context,
uint32_t hint, uint32_t hint,
uint32_t purpose) uint32_t purpose)
{ {
@ -131,7 +131,7 @@ handle_content_type(void *data,
static void static void
handle_invoke_action(void *data, handle_invoke_action(void *data,
struct input_method_context *context, struct wl_input_method_context *context,
uint32_t button, uint32_t button,
uint32_t index) uint32_t index)
{ {
@ -139,7 +139,7 @@ handle_invoke_action(void *data,
static void static void
handle_commit_state(void *data, handle_commit_state(void *data,
struct input_method_context *context, struct wl_input_method_context *context,
uint32_t serial) uint32_t serial)
{ {
struct simple_im *keyboard = data; struct simple_im *keyboard = data;
@ -149,12 +149,12 @@ handle_commit_state(void *data,
static void static void
handle_preferred_language(void *data, handle_preferred_language(void *data,
struct input_method_context *context, struct wl_input_method_context *context,
const char *language) const char *language)
{ {
} }
static const struct input_method_context_listener input_method_context_listener = { static const struct wl_input_method_context_listener input_method_context_listener = {
handle_surrounding_text, handle_surrounding_text,
handle_reset, handle_reset,
handle_content_type, handle_content_type,
@ -253,7 +253,7 @@ input_method_keyboard_modifiers(void *data,
uint32_t group) uint32_t group)
{ {
struct simple_im *keyboard = data; struct simple_im *keyboard = data;
struct input_method_context *context = keyboard->context; struct wl_input_method_context *context = keyboard->context;
xkb_mod_mask_t mask; xkb_mod_mask_t mask;
xkb_state_update_mask(keyboard->state, mods_depressed, xkb_state_update_mask(keyboard->state, mods_depressed,
@ -270,9 +270,9 @@ input_method_keyboard_modifiers(void *data,
if (mask & keyboard->shift_mask) if (mask & keyboard->shift_mask)
keyboard->modifiers |= MOD_SHIFT_MASK; keyboard->modifiers |= MOD_SHIFT_MASK;
input_method_context_modifiers(context, serial, wl_input_method_context_modifiers(context, serial,
mods_depressed, mods_depressed, mods_depressed, mods_depressed,
mods_latched, group); mods_latched, group);
} }
static const struct wl_keyboard_listener input_method_keyboard_listener = { static const struct wl_keyboard_listener input_method_keyboard_listener = {
@ -285,23 +285,23 @@ static const struct wl_keyboard_listener input_method_keyboard_listener = {
static void static void
input_method_activate(void *data, input_method_activate(void *data,
struct input_method *input_method, struct wl_input_method *input_method,
struct input_method_context *context) struct wl_input_method_context *context)
{ {
struct simple_im *keyboard = data; struct simple_im *keyboard = data;
if (keyboard->context) if (keyboard->context)
input_method_context_destroy(keyboard->context); wl_input_method_context_destroy(keyboard->context);
keyboard->compose_state = state_normal; keyboard->compose_state = state_normal;
keyboard->serial = 0; keyboard->serial = 0;
keyboard->context = context; keyboard->context = context;
input_method_context_add_listener(context, wl_input_method_context_add_listener(context,
&input_method_context_listener, &input_method_context_listener,
keyboard); keyboard);
keyboard->keyboard = input_method_context_grab_keyboard(context); keyboard->keyboard = wl_input_method_context_grab_keyboard(context);
wl_keyboard_add_listener(keyboard->keyboard, wl_keyboard_add_listener(keyboard->keyboard,
&input_method_keyboard_listener, &input_method_keyboard_listener,
keyboard); keyboard);
@ -309,19 +309,19 @@ input_method_activate(void *data,
static void static void
input_method_deactivate(void *data, input_method_deactivate(void *data,
struct input_method *input_method, struct wl_input_method *input_method,
struct input_method_context *context) struct wl_input_method_context *context)
{ {
struct simple_im *keyboard = data; struct simple_im *keyboard = data;
if (!keyboard->context) if (!keyboard->context)
return; return;
input_method_context_destroy(keyboard->context); wl_input_method_context_destroy(keyboard->context);
keyboard->context = NULL; keyboard->context = NULL;
} }
static const struct input_method_listener input_method_listener = { static const struct wl_input_method_listener input_method_listener = {
input_method_activate, input_method_activate,
input_method_deactivate input_method_deactivate
}; };
@ -332,12 +332,12 @@ registry_handle_global(void *data, struct wl_registry *registry,
{ {
struct simple_im *keyboard = data; struct simple_im *keyboard = data;
if (!strcmp(interface, "input_method")) { if (!strcmp(interface, "wl_input_method")) {
keyboard->input_method = keyboard->input_method =
wl_registry_bind(registry, name, wl_registry_bind(registry, name,
&input_method_interface, 1); &wl_input_method_interface, 1);
input_method_add_listener(keyboard->input_method, wl_input_method_add_listener(keyboard->input_method,
&input_method_listener, keyboard); &input_method_listener, keyboard);
} }
} }
@ -376,7 +376,7 @@ simple_im_key_handler(struct simple_im *keyboard,
uint32_t serial, uint32_t time, uint32_t key, uint32_t sym, uint32_t serial, uint32_t time, uint32_t key, uint32_t sym,
enum wl_keyboard_key_state state) enum wl_keyboard_key_state state)
{ {
struct input_method_context *context = keyboard->context; struct wl_input_method_context *context = keyboard->context;
char text[64]; char text[64];
if (sym == XKB_KEY_Multi_key && if (sym == XKB_KEY_Multi_key &&
@ -396,7 +396,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++) { for (i = 0; i < sizeof(ignore_keys_on_compose) / sizeof(ignore_keys_on_compose[0]); i++) {
if (sym == ignore_keys_on_compose[i]) { if (sym == ignore_keys_on_compose[i]) {
input_method_context_key(context, keyboard->serial, time, key, state); wl_input_method_context_key(context, keyboard->serial, time, key, state);
return; return;
} }
} }
@ -411,16 +411,16 @@ simple_im_key_handler(struct simple_im *keyboard,
if (cs) { if (cs) {
if (cs->keys[i + 1] == 0) { if (cs->keys[i + 1] == 0) {
input_method_context_preedit_cursor(keyboard->context, wl_input_method_context_preedit_cursor(keyboard->context,
0); 0);
input_method_context_preedit_string(keyboard->context, wl_input_method_context_preedit_string(keyboard->context,
keyboard->serial, keyboard->serial,
"", ""); "", "");
input_method_context_cursor_position(keyboard->context, wl_input_method_context_cursor_position(keyboard->context,
0, 0); 0, 0);
input_method_context_commit_string(keyboard->context, wl_input_method_context_commit_string(keyboard->context,
keyboard->serial, keyboard->serial,
cs->text); cs->text);
keyboard->compose_state = state_normal; keyboard->compose_state = state_normal;
} else { } else {
uint32_t j = 0, idx = 0; uint32_t j = 0, idx = 0;
@ -429,12 +429,12 @@ simple_im_key_handler(struct simple_im *keyboard,
idx += xkb_keysym_to_utf8(cs->keys[j], text + idx, sizeof(text) - idx); idx += xkb_keysym_to_utf8(cs->keys[j], text + idx, sizeof(text) - idx);
} }
input_method_context_preedit_cursor(keyboard->context, wl_input_method_context_preedit_cursor(keyboard->context,
strlen(text)); strlen(text));
input_method_context_preedit_string(keyboard->context, wl_input_method_context_preedit_string(keyboard->context,
keyboard->serial, keyboard->serial,
text, text,
text); text);
} }
} else { } else {
uint32_t j = 0, idx = 0; uint32_t j = 0, idx = 0;
@ -442,34 +442,34 @@ simple_im_key_handler(struct simple_im *keyboard,
for (; j <= i; j++) { for (; j <= i; j++) {
idx += xkb_keysym_to_utf8(keyboard->compose_seq.keys[j], text + idx, sizeof(text) - idx); idx += xkb_keysym_to_utf8(keyboard->compose_seq.keys[j], text + idx, sizeof(text) - idx);
} }
input_method_context_preedit_cursor(keyboard->context, wl_input_method_context_preedit_cursor(keyboard->context,
0); 0);
input_method_context_preedit_string(keyboard->context, wl_input_method_context_preedit_string(keyboard->context,
keyboard->serial, keyboard->serial,
"", ""); "", "");
input_method_context_cursor_position(keyboard->context, wl_input_method_context_cursor_position(keyboard->context,
0, 0); 0, 0);
input_method_context_commit_string(keyboard->context, wl_input_method_context_commit_string(keyboard->context,
keyboard->serial, keyboard->serial,
text); text);
keyboard->compose_state = state_normal; keyboard->compose_state = state_normal;
} }
return; return;
} }
if (xkb_keysym_to_utf8(sym, text, sizeof(text)) <= 0) { if (xkb_keysym_to_utf8(sym, text, sizeof(text)) <= 0) {
input_method_context_key(context, serial, time, key, state); wl_input_method_context_key(context, serial, time, key, state);
return; return;
} }
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
return; return;
input_method_context_cursor_position(keyboard->context, wl_input_method_context_cursor_position(keyboard->context,
0, 0); 0, 0);
input_method_context_commit_string(keyboard->context, wl_input_method_context_commit_string(keyboard->context,
keyboard->serial, keyboard->serial,
text); text);
} }
int int

@ -26,7 +26,7 @@
</copyright> </copyright>
<interface name="input_method_context" version="1"> <interface name="wl_input_method_context" version="1">
<description summary="input method context"> <description summary="input method context">
Corresponds to a text model on input method side. An input method context Corresponds to a text model on input method side. An input method context
is created on text mode activation on the input method side. It allows to is created on text mode activation on the input method side. It allows to
@ -215,7 +215,7 @@
</event> </event>
</interface> </interface>
<interface name="input_method" version="1"> <interface name="wl_input_method" version="1">
<description summary="input method"> <description summary="input method">
An input method object is responsible to compose text in response to An input method object is responsible to compose text in response to
input from hardware or virtual keyboards. There is one input method input from hardware or virtual keyboards. There is one input method
@ -227,7 +227,7 @@
A text model was activated. Creates an input method context object A text model was activated. Creates an input method context object
which allows communication with the text model. which allows communication with the text model.
</description> </description>
<arg name="id" type="new_id" interface="input_method_context"/> <arg name="id" type="new_id" interface="wl_input_method_context"/>
</event> </event>
<event name="deactivate"> <event name="deactivate">
<description summary="activate event"> <description summary="activate event">
@ -235,22 +235,22 @@
The input method context should be destroyed after deactivation is The input method context should be destroyed after deactivation is
handled. handled.
</description> </description>
<arg name="context" type="object" interface="input_method_context"/> <arg name="context" type="object" interface="wl_input_method_context"/>
</event> </event>
</interface> </interface>
<interface name="input_panel" version="1"> <interface name="wl_input_panel" version="1">
<description summary="interface for implementing keyboards"> <description summary="interface for implementing keyboards">
Only one client can bind this interface at a time. Only one client can bind this interface at a time.
</description> </description>
<request name="get_input_panel_surface"> <request name="get_input_panel_surface">
<arg name="id" type="new_id" interface="input_panel_surface"/> <arg name="id" type="new_id" interface="wl_input_panel_surface"/>
<arg name="surface" type="object" interface="wl_surface"/> <arg name="surface" type="object" interface="wl_surface"/>
</request> </request>
</interface> </interface>
<interface name="input_panel_surface" version="1"> <interface name="wl_input_panel_surface" version="1">
<enum name="position"> <enum name="position">
<entry name="center_bottom" value="0"/> <entry name="center_bottom" value="0"/>
</enum> </enum>

@ -3650,7 +3650,7 @@ input_panel_surface_set_overlay_panel(struct wl_client *client,
input_panel_surface->panel = 1; input_panel_surface->panel = 1;
} }
static const struct input_panel_surface_interface input_panel_surface_implementation = { static const struct wl_input_panel_surface_interface input_panel_surface_implementation = {
input_panel_surface_set_toplevel, input_panel_surface_set_toplevel,
input_panel_surface_set_overlay_panel input_panel_surface_set_overlay_panel
}; };
@ -3676,7 +3676,7 @@ input_panel_get_input_panel_surface(struct wl_client *client,
if (get_input_panel_surface(surface)) { if (get_input_panel_surface(surface)) {
wl_resource_post_error(surface_resource, wl_resource_post_error(surface_resource,
WL_DISPLAY_ERROR_INVALID_OBJECT, WL_DISPLAY_ERROR_INVALID_OBJECT,
"input_panel::get_input_panel_surface already requested"); "wl_input_panel::get_input_panel_surface already requested");
return; return;
} }
@ -3690,7 +3690,7 @@ input_panel_get_input_panel_surface(struct wl_client *client,
ipsurf->resource.destroy = destroy_input_panel_surface_resource; ipsurf->resource.destroy = destroy_input_panel_surface_resource;
ipsurf->resource.object.id = id; ipsurf->resource.object.id = id;
ipsurf->resource.object.interface = &input_panel_surface_interface; ipsurf->resource.object.interface = &wl_input_panel_surface_interface;
ipsurf->resource.object.implementation = ipsurf->resource.object.implementation =
(void (**)(void)) &input_panel_surface_implementation; (void (**)(void)) &input_panel_surface_implementation;
ipsurf->resource.data = ipsurf; ipsurf->resource.data = ipsurf;
@ -3698,7 +3698,7 @@ input_panel_get_input_panel_surface(struct wl_client *client,
wl_client_add_resource(client, &ipsurf->resource); wl_client_add_resource(client, &ipsurf->resource);
} }
static const struct input_panel_interface input_panel_implementation = { static const struct wl_input_panel_interface input_panel_implementation = {
input_panel_get_input_panel_surface input_panel_get_input_panel_surface
}; };
@ -3718,7 +3718,7 @@ bind_input_panel(struct wl_client *client,
struct desktop_shell *shell = data; struct desktop_shell *shell = data;
struct wl_resource *resource; struct wl_resource *resource;
resource = wl_client_add_object(client, &input_panel_interface, resource = wl_client_add_object(client, &wl_input_panel_interface,
&input_panel_implementation, &input_panel_implementation,
id, shell); id, shell);
@ -4313,7 +4313,7 @@ module_init(struct weston_compositor *ec,
shell, bind_screensaver) == NULL) shell, bind_screensaver) == NULL)
return -1; return -1;
if (wl_display_add_global(ec->wl_display, &input_panel_interface, if (wl_display_add_global(ec->wl_display, &wl_input_panel_interface,
shell, bind_input_panel) == NULL) shell, bind_input_panel) == NULL)
return -1; return -1;

@ -112,8 +112,8 @@ deactivate_text_input(struct text_input *text_input,
if (input_method->model == text_input) { if (input_method->model == text_input) {
if (input_method->context && input_method->input_method_binding) { if (input_method->context && input_method->input_method_binding) {
input_method_context_end_keyboard_grab(input_method->context); input_method_context_end_keyboard_grab(input_method->context);
input_method_send_deactivate(input_method->input_method_binding, wl_input_method_send_deactivate(input_method->input_method_binding,
&input_method->context->resource); &input_method->context->resource);
} }
wl_list_remove(&input_method->link); wl_list_remove(&input_method->link);
@ -150,16 +150,16 @@ text_input_set_surrounding_text(struct wl_client *client,
wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) { wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) {
if (!input_method->context) if (!input_method->context)
continue; continue;
input_method_context_send_surrounding_text(&input_method->context->resource, wl_input_method_context_send_surrounding_text(&input_method->context->resource,
text, text,
cursor, cursor,
anchor); anchor);
} }
} }
static void static void
text_input_activate(struct wl_client *client, text_input_activate(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
struct wl_resource *seat, struct wl_resource *seat,
struct wl_resource *surface) struct wl_resource *surface)
{ {
@ -215,7 +215,7 @@ text_input_reset(struct wl_client *client,
wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) { wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) {
if (!input_method->context) if (!input_method->context)
continue; continue;
input_method_context_send_reset(&input_method->context->resource); wl_input_method_context_send_reset(&input_method->context->resource);
} }
} }
@ -250,7 +250,7 @@ text_input_set_content_type(struct wl_client *client,
wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) { wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) {
if (!input_method->context) if (!input_method->context)
continue; continue;
input_method_context_send_content_type(&input_method->context->resource, hint, purpose); wl_input_method_context_send_content_type(&input_method->context->resource, hint, purpose);
} }
} }
@ -266,7 +266,7 @@ text_input_invoke_action(struct wl_client *client,
wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) { wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) {
if (!input_method->context) if (!input_method->context)
continue; continue;
input_method_context_send_invoke_action(&input_method->context->resource, button, index); wl_input_method_context_send_invoke_action(&input_method->context->resource, button, index);
} }
} }
@ -281,7 +281,7 @@ text_input_commit_state(struct wl_client *client,
wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) { wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) {
if (!input_method->context) if (!input_method->context)
continue; continue;
input_method_context_send_commit_state(&input_method->context->resource, serial); wl_input_method_context_send_commit_state(&input_method->context->resource, serial);
} }
} }
@ -324,8 +324,8 @@ text_input_set_preferred_language(struct wl_client *client,
wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) { wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) {
if (!input_method->context) if (!input_method->context)
continue; continue;
input_method_context_send_preferred_language(&input_method->context->resource, wl_input_method_context_send_preferred_language(&input_method->context->resource,
language); language);
} }
} }
@ -512,7 +512,7 @@ input_method_context_keysym(struct wl_client *client,
struct input_method_context *context = resource->data; struct input_method_context *context = resource->data;
wl_text_input_send_keysym(&context->model->resource, serial, time, wl_text_input_send_keysym(&context->model->resource, serial, time,
sym, state, modifiers); sym, state, modifiers);
} }
static void static void
@ -650,7 +650,7 @@ input_method_context_text_direction(struct wl_client *client,
} }
static const struct input_method_context_interface input_method_context_implementation = { static const struct wl_input_method_context_interface input_method_context_implementation = {
input_method_context_destroy, input_method_context_destroy,
input_method_context_commit_string, input_method_context_commit_string,
input_method_context_preedit_string, input_method_context_preedit_string,
@ -694,7 +694,7 @@ input_method_context_create(struct text_input *model,
context->resource.destroy = destroy_input_method_context; context->resource.destroy = destroy_input_method_context;
context->resource.object.id = 0; context->resource.object.id = 0;
context->resource.object.interface = &input_method_context_interface; context->resource.object.interface = &wl_input_method_context_interface;
context->resource.object.implementation = context->resource.object.implementation =
(void (**)(void)) &input_method_context_implementation; (void (**)(void)) &input_method_context_implementation;
context->resource.data = context; context->resource.data = context;
@ -706,7 +706,7 @@ input_method_context_create(struct text_input *model,
wl_client_add_resource(input_method->input_method_binding->client, &context->resource); wl_client_add_resource(input_method->input_method_binding->client, &context->resource);
input_method_send_activate(input_method->input_method_binding, &context->resource); wl_input_method_send_activate(input_method->input_method_binding, &context->resource);
} }
static void static void
@ -748,7 +748,7 @@ bind_input_method(struct wl_client *client,
struct text_backend *text_backend = input_method->text_backend; struct text_backend *text_backend = input_method->text_backend;
struct wl_resource *resource; struct wl_resource *resource;
resource = wl_client_add_object(client, &input_method_interface, resource = wl_client_add_object(client, &wl_input_method_interface,
NULL, NULL,
id, input_method); id, input_method);
@ -841,9 +841,9 @@ launch_input_method(struct text_backend *text_backend)
return; return;
text_backend->input_method.client = weston_client_launch(text_backend->compositor, text_backend->input_method.client = weston_client_launch(text_backend->compositor,
&text_backend->input_method.process, &text_backend->input_method.process,
text_backend->input_method.path, text_backend->input_method.path,
handle_input_method_sigchld); handle_input_method_sigchld);
if (!text_backend->input_method.client) if (!text_backend->input_method.client)
weston_log("not able to start %s\n", text_backend->input_method.path); weston_log("not able to start %s\n", text_backend->input_method.path);
@ -870,7 +870,7 @@ handle_seat_created(struct wl_listener *listener,
input_method->input_method_global = input_method->input_method_global =
wl_display_add_global(ec->wl_display, wl_display_add_global(ec->wl_display,
&input_method_interface, &wl_input_method_interface,
input_method, bind_input_method); input_method, bind_input_method);
input_method->destroy_listener.notify = input_method_notifier_destroy; input_method->destroy_listener.notify = input_method_notifier_destroy;

Loading…
Cancel
Save