|
|
|
@ -129,8 +129,9 @@ 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(input_method->input_method_binding, |
|
|
|
|
input_method->context->resource); |
|
|
|
|
wl_input_method_send_deactivate( |
|
|
|
|
input_method->input_method_binding, |
|
|
|
|
input_method->context->resource); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
wl_list_remove(&input_method->link); |
|
|
|
@ -152,7 +153,8 @@ destroy_text_input(struct wl_resource *resource) |
|
|
|
|
struct text_input *text_input = wl_resource_get_user_data(resource); |
|
|
|
|
struct input_method *input_method, *next; |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
deactivate_input_method(input_method); |
|
|
|
|
|
|
|
|
|
free(text_input); |
|
|
|
@ -168,13 +170,12 @@ text_input_set_surrounding_text(struct wl_client *client, |
|
|
|
|
struct text_input *text_input = wl_resource_get_user_data(resource); |
|
|
|
|
struct input_method *input_method, *next; |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
continue; |
|
|
|
|
wl_input_method_context_send_surrounding_text(input_method->context->resource, |
|
|
|
|
text, |
|
|
|
|
cursor, |
|
|
|
|
anchor); |
|
|
|
|
wl_input_method_context_send_surrounding_text( |
|
|
|
|
input_method->context->resource, text, cursor, anchor); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -213,12 +214,15 @@ text_input_activate(struct wl_client *client, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (text_input->input_panel_visible) { |
|
|
|
|
wl_signal_emit(&ec->show_input_panel_signal, text_input->surface); |
|
|
|
|
wl_signal_emit(&ec->update_input_panel_signal, &text_input->cursor_rectangle); |
|
|
|
|
wl_signal_emit(&ec->show_input_panel_signal, |
|
|
|
|
text_input->surface); |
|
|
|
|
wl_signal_emit(&ec->update_input_panel_signal, |
|
|
|
|
&text_input->cursor_rectangle); |
|
|
|
|
text_input->manager->current_panel = text_input; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
wl_text_input_send_enter(text_input->resource, text_input->surface->resource); |
|
|
|
|
wl_text_input_send_enter(text_input->resource, |
|
|
|
|
text_input->surface->resource); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
@ -239,10 +243,12 @@ text_input_reset(struct wl_client *client, |
|
|
|
|
struct text_input *text_input = wl_resource_get_user_data(resource); |
|
|
|
|
struct input_method *input_method, *next; |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
continue; |
|
|
|
|
wl_input_method_context_send_reset(input_method->context->resource); |
|
|
|
|
wl_input_method_context_send_reset( |
|
|
|
|
input_method->context->resource); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -262,7 +268,8 @@ text_input_set_cursor_rectangle(struct wl_client *client, |
|
|
|
|
text_input->cursor_rectangle.x2 = x + width; |
|
|
|
|
text_input->cursor_rectangle.y2 = y + height; |
|
|
|
|
|
|
|
|
|
wl_signal_emit(&ec->update_input_panel_signal, &text_input->cursor_rectangle); |
|
|
|
|
wl_signal_emit(&ec->update_input_panel_signal, |
|
|
|
|
&text_input->cursor_rectangle); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
@ -274,10 +281,12 @@ text_input_set_content_type(struct wl_client *client, |
|
|
|
|
struct text_input *text_input = wl_resource_get_user_data(resource); |
|
|
|
|
struct input_method *input_method, *next; |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
continue; |
|
|
|
|
wl_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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -290,10 +299,12 @@ text_input_invoke_action(struct wl_client *client, |
|
|
|
|
struct text_input *text_input = wl_resource_get_user_data(resource); |
|
|
|
|
struct input_method *input_method, *next; |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
continue; |
|
|
|
|
wl_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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -305,10 +316,12 @@ text_input_commit_state(struct wl_client *client, |
|
|
|
|
struct text_input *text_input = wl_resource_get_user_data(resource); |
|
|
|
|
struct input_method *input_method, *next; |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
continue; |
|
|
|
|
wl_input_method_context_send_commit_state(input_method->context->resource, serial); |
|
|
|
|
wl_input_method_context_send_commit_state( |
|
|
|
|
input_method->context->resource, serial); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -322,8 +335,10 @@ text_input_show_input_panel(struct wl_client *client, |
|
|
|
|
text_input->input_panel_visible = true; |
|
|
|
|
|
|
|
|
|
if (!wl_list_empty(&text_input->input_methods)) { |
|
|
|
|
wl_signal_emit(&ec->show_input_panel_signal, text_input->surface); |
|
|
|
|
wl_signal_emit(&ec->update_input_panel_signal, &text_input->cursor_rectangle); |
|
|
|
|
wl_signal_emit(&ec->show_input_panel_signal, |
|
|
|
|
text_input->surface); |
|
|
|
|
wl_signal_emit(&ec->update_input_panel_signal, |
|
|
|
|
&text_input->cursor_rectangle); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -351,11 +366,12 @@ text_input_set_preferred_language(struct wl_client *client, |
|
|
|
|
struct text_input *text_input = wl_resource_get_user_data(resource); |
|
|
|
|
struct input_method *input_method, *next; |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
continue; |
|
|
|
|
wl_input_method_context_send_preferred_language(input_method->context->resource, |
|
|
|
|
language); |
|
|
|
|
wl_input_method_context_send_preferred_language( |
|
|
|
|
input_method->context->resource, language); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -377,7 +393,8 @@ static void text_input_manager_create_text_input(struct wl_client *client, |
|
|
|
|
struct wl_resource *resource, |
|
|
|
|
uint32_t id) |
|
|
|
|
{ |
|
|
|
|
struct text_input_manager *text_input_manager = wl_resource_get_user_data(resource); |
|
|
|
|
struct text_input_manager *text_input_manager = |
|
|
|
|
wl_resource_get_user_data(resource); |
|
|
|
|
struct text_input *text_input; |
|
|
|
|
|
|
|
|
|
text_input = zalloc(sizeof *text_input); |
|
|
|
@ -396,7 +413,7 @@ static void text_input_manager_create_text_input(struct wl_client *client, |
|
|
|
|
wl_list_init(&text_input->input_methods); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static const struct wl_text_input_manager_interface text_input_manager_implementation = { |
|
|
|
|
static const struct wl_text_input_manager_interface manager_implementation = { |
|
|
|
|
text_input_manager_create_text_input |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -415,7 +432,7 @@ bind_text_input_manager(struct wl_client *client, |
|
|
|
|
&wl_text_input_manager_interface, 1, id); |
|
|
|
|
if (resource) |
|
|
|
|
wl_resource_set_implementation(resource, |
|
|
|
|
&text_input_manager_implementation, |
|
|
|
|
&manager_implementation, |
|
|
|
|
text_input_manager, NULL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -423,7 +440,9 @@ static void |
|
|
|
|
text_input_manager_notifier_destroy(struct wl_listener *listener, void *data) |
|
|
|
|
{ |
|
|
|
|
struct text_input_manager *text_input_manager = |
|
|
|
|
container_of(listener, struct text_input_manager, destroy_listener); |
|
|
|
|
container_of(listener, |
|
|
|
|
struct text_input_manager, |
|
|
|
|
destroy_listener); |
|
|
|
|
|
|
|
|
|
wl_global_destroy(text_input_manager->text_input_manager_global); |
|
|
|
|
|
|
|
|
@ -446,8 +465,10 @@ text_input_manager_create(struct weston_compositor *ec) |
|
|
|
|
&wl_text_input_manager_interface, 1, |
|
|
|
|
text_input_manager, bind_text_input_manager); |
|
|
|
|
|
|
|
|
|
text_input_manager->destroy_listener.notify = text_input_manager_notifier_destroy; |
|
|
|
|
wl_signal_add(&ec->destroy_signal, &text_input_manager->destroy_listener); |
|
|
|
|
text_input_manager->destroy_listener.notify = |
|
|
|
|
text_input_manager_notifier_destroy; |
|
|
|
|
wl_signal_add(&ec->destroy_signal, |
|
|
|
|
&text_input_manager->destroy_listener); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
@ -524,8 +545,8 @@ input_method_context_delete_surrounding_text(struct wl_client *client, |
|
|
|
|
wl_resource_get_user_data(resource); |
|
|
|
|
|
|
|
|
|
if (context->input) |
|
|
|
|
wl_text_input_send_delete_surrounding_text(context->input->resource, |
|
|
|
|
index, length); |
|
|
|
|
wl_text_input_send_delete_surrounding_text( |
|
|
|
|
context->input->resource, index, length); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
@ -592,16 +613,20 @@ input_method_context_grab_key(struct weston_keyboard_grab *grab, |
|
|
|
|
if (!keyboard->input_method_resource) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
display = wl_client_get_display(wl_resource_get_client(keyboard->input_method_resource)); |
|
|
|
|
display = wl_client_get_display( |
|
|
|
|
wl_resource_get_client(keyboard->input_method_resource)); |
|
|
|
|
serial = wl_display_next_serial(display); |
|
|
|
|
wl_keyboard_send_key(keyboard->input_method_resource, |
|
|
|
|
serial, time, key, state_w); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
input_method_context_grab_modifier(struct weston_keyboard_grab *grab, uint32_t serial, |
|
|
|
|
uint32_t mods_depressed, uint32_t mods_latched, |
|
|
|
|
uint32_t mods_locked, uint32_t group) |
|
|
|
|
input_method_context_grab_modifier(struct weston_keyboard_grab *grab, |
|
|
|
|
uint32_t serial, |
|
|
|
|
uint32_t mods_depressed, |
|
|
|
|
uint32_t mods_latched, |
|
|
|
|
uint32_t mods_locked, |
|
|
|
|
uint32_t group) |
|
|
|
|
{ |
|
|
|
|
struct weston_keyboard *keyboard = grab->keyboard; |
|
|
|
|
|
|
|
|
@ -630,7 +655,8 @@ input_method_context_grab_keyboard(struct wl_client *client, |
|
|
|
|
struct wl_resource *resource, |
|
|
|
|
uint32_t id) |
|
|
|
|
{ |
|
|
|
|
struct input_method_context *context = wl_resource_get_user_data(resource); |
|
|
|
|
struct input_method_context *context = |
|
|
|
|
wl_resource_get_user_data(resource); |
|
|
|
|
struct wl_resource *cr; |
|
|
|
|
struct weston_seat *seat = context->input_method->seat; |
|
|
|
|
struct weston_keyboard *keyboard = seat->keyboard; |
|
|
|
@ -659,7 +685,8 @@ input_method_context_key(struct wl_client *client, |
|
|
|
|
uint32_t key, |
|
|
|
|
uint32_t state_w) |
|
|
|
|
{ |
|
|
|
|
struct input_method_context *context = wl_resource_get_user_data(resource); |
|
|
|
|
struct input_method_context *context = |
|
|
|
|
wl_resource_get_user_data(resource); |
|
|
|
|
struct weston_seat *seat = context->input_method->seat; |
|
|
|
|
struct weston_keyboard *keyboard = seat->keyboard; |
|
|
|
|
struct weston_keyboard_grab *default_grab = &keyboard->default_grab; |
|
|
|
@ -676,7 +703,8 @@ input_method_context_modifiers(struct wl_client *client, |
|
|
|
|
uint32_t mods_locked, |
|
|
|
|
uint32_t group) |
|
|
|
|
{ |
|
|
|
|
struct input_method_context *context = wl_resource_get_user_data(resource); |
|
|
|
|
struct input_method_context *context = |
|
|
|
|
wl_resource_get_user_data(resource); |
|
|
|
|
|
|
|
|
|
struct weston_seat *seat = context->input_method->seat; |
|
|
|
|
struct weston_keyboard *keyboard = seat->keyboard; |
|
|
|
@ -694,7 +722,8 @@ input_method_context_language(struct wl_client *client, |
|
|
|
|
uint32_t serial, |
|
|
|
|
const char *language) |
|
|
|
|
{ |
|
|
|
|
struct input_method_context *context = wl_resource_get_user_data(resource); |
|
|
|
|
struct input_method_context *context = |
|
|
|
|
wl_resource_get_user_data(resource); |
|
|
|
|
|
|
|
|
|
if (context->input) |
|
|
|
|
wl_text_input_send_language(context->input->resource, |
|
|
|
@ -707,7 +736,8 @@ input_method_context_text_direction(struct wl_client *client, |
|
|
|
|
uint32_t serial, |
|
|
|
|
uint32_t direction) |
|
|
|
|
{ |
|
|
|
|
struct input_method_context *context = wl_resource_get_user_data(resource); |
|
|
|
|
struct input_method_context *context = |
|
|
|
|
wl_resource_get_user_data(resource); |
|
|
|
|
|
|
|
|
|
if (context->input) |
|
|
|
|
wl_text_input_send_text_direction(context->input->resource, |
|
|
|
@ -715,7 +745,7 @@ input_method_context_text_direction(struct wl_client *client, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const struct wl_input_method_context_interface input_method_context_implementation = { |
|
|
|
|
static const struct wl_input_method_context_interface context_implementation = { |
|
|
|
|
input_method_context_destroy, |
|
|
|
|
input_method_context_commit_string, |
|
|
|
|
input_method_context_preedit_string, |
|
|
|
@ -735,11 +765,11 @@ static const struct wl_input_method_context_interface input_method_context_imple |
|
|
|
|
static void |
|
|
|
|
destroy_input_method_context(struct wl_resource *resource) |
|
|
|
|
{ |
|
|
|
|
struct input_method_context *context = wl_resource_get_user_data(resource); |
|
|
|
|
struct input_method_context *context = |
|
|
|
|
wl_resource_get_user_data(resource); |
|
|
|
|
|
|
|
|
|
if (context->keyboard) { |
|
|
|
|
if (context->keyboard) |
|
|
|
|
wl_resource_destroy(context->keyboard); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (context->input_method && context->input_method->context == context) |
|
|
|
|
context->input_method->context = NULL; |
|
|
|
@ -766,7 +796,7 @@ input_method_context_create(struct text_input *input, |
|
|
|
|
wl_resource_create(wl_resource_get_client(binding), |
|
|
|
|
&wl_input_method_context_interface, 1, 0); |
|
|
|
|
wl_resource_set_implementation(context->resource, |
|
|
|
|
&input_method_context_implementation, |
|
|
|
|
&context_implementation, |
|
|
|
|
context, destroy_input_method_context); |
|
|
|
|
|
|
|
|
|
context->input = input; |
|
|
|
@ -823,14 +853,17 @@ bind_input_method(struct wl_client *client, |
|
|
|
|
wl_resource_create(client, &wl_input_method_interface, 1, id); |
|
|
|
|
|
|
|
|
|
if (input_method->input_method_binding != NULL) { |
|
|
|
|
wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, |
|
|
|
|
wl_resource_post_error(resource, |
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT, |
|
|
|
|
"interface object already bound"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (text_backend->input_method.client != client) { |
|
|
|
|
wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, |
|
|
|
|
"permission to bind input_method denied"); |
|
|
|
|
wl_resource_post_error(resource, |
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT, |
|
|
|
|
"permission to bind " |
|
|
|
|
"input_method denied"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -861,7 +894,8 @@ handle_keyboard_focus(struct wl_listener *listener, void *data) |
|
|
|
|
{ |
|
|
|
|
struct weston_keyboard *keyboard = data; |
|
|
|
|
struct input_method *input_method = |
|
|
|
|
container_of(listener, struct input_method, keyboard_focus_listener); |
|
|
|
|
container_of(listener, struct input_method, |
|
|
|
|
keyboard_focus_listener); |
|
|
|
|
struct weston_surface *surface = keyboard->focus; |
|
|
|
|
|
|
|
|
|
if (!input_method->input) |
|
|
|
@ -878,9 +912,12 @@ input_method_init_seat(struct weston_seat *seat) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (seat->keyboard) { |
|
|
|
|
seat->input_method->keyboard_focus_listener.notify = handle_keyboard_focus; |
|
|
|
|
wl_signal_add(&seat->keyboard->focus_signal, &seat->input_method->keyboard_focus_listener); |
|
|
|
|
seat->keyboard->input_method_grab.interface = &input_method_context_grab; |
|
|
|
|
seat->input_method->keyboard_focus_listener.notify = |
|
|
|
|
handle_keyboard_focus; |
|
|
|
|
wl_signal_add(&seat->keyboard->focus_signal, |
|
|
|
|
&seat->input_method->keyboard_focus_listener); |
|
|
|
|
seat->keyboard->input_method_grab.interface = |
|
|
|
|
&input_method_context_grab; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
seat->input_method->focus_listener_initialized = 1; |
|
|
|
@ -930,13 +967,15 @@ launch_input_method(struct text_backend *text_backend) |
|
|
|
|
if (text_backend->input_method.process.pid != 0) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
text_backend->input_method.client = weston_client_launch(text_backend->compositor, |
|
|
|
|
&text_backend->input_method.process, |
|
|
|
|
text_backend->input_method.path, |
|
|
|
|
handle_input_method_sigchld); |
|
|
|
|
text_backend->input_method.client = |
|
|
|
|
weston_client_launch(text_backend->compositor, |
|
|
|
|
&text_backend->input_method.process, |
|
|
|
|
text_backend->input_method.path, |
|
|
|
|
handle_input_method_sigchld); |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|