From 62ece76b1e519b5356dfb6eaba260872a3c96bdf Mon Sep 17 00:00:00 2001 From: Jan Arne Petersen Date: Thu, 18 Apr 2013 16:47:36 +0200 Subject: [PATCH] text: Rename text_input to wl_text_input Signed-off-by: Jan Arne Petersen --- clients/editor.c | 118 ++++++++++++++++++++++++++--------------------------- clients/keyboard.c | 10 ++--- protocol/text.xml | 8 ++-- src/text-backend.c | 34 +++++++-------- tests/text-test.c | 50 +++++++++++------------ 5 files changed, 110 insertions(+), 110 deletions(-) diff --git a/clients/editor.c b/clients/editor.c index 27e4900..79ee8c5 100644 --- a/clients/editor.c +++ b/clients/editor.c @@ -59,7 +59,7 @@ struct text_entry { uint32_t delete_index; uint32_t delete_length; } pending_commit; - struct text_input *text_input; + struct wl_text_input *text_input; PangoLayout *layout; struct { xkb_mod_mask_t shift_mask; @@ -72,7 +72,7 @@ struct text_entry { }; struct editor { - struct text_input_manager *text_input_manager; + struct wl_text_input_manager *text_input_manager; struct display *display; struct window *window; struct widget *widget; @@ -146,7 +146,7 @@ static void text_entry_update(struct text_entry *entry); static void text_input_commit_string(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t serial, const char *text) { @@ -179,7 +179,7 @@ text_input_commit_string(void *data, static void text_input_preedit_string(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t serial, const char *text, const char *commit) @@ -195,13 +195,13 @@ text_input_preedit_string(void *data, entry->preedit_info.attr_list = NULL; text_entry_update(entry); - + widget_schedule_redraw(entry->widget); } static void text_input_delete_surrounding_text(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, int32_t index, uint32_t length) { @@ -228,7 +228,7 @@ text_input_delete_surrounding_text(void *data, static void text_input_cursor_position(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, int32_t index, int32_t anchor) { @@ -240,7 +240,7 @@ text_input_cursor_position(void *data, static void text_input_preedit_styling(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t index, uint32_t length, uint32_t style) @@ -253,24 +253,24 @@ text_input_preedit_styling(void *data, entry->preedit_info.attr_list = pango_attr_list_new(); switch (style) { - case TEXT_INPUT_PREEDIT_STYLE_DEFAULT: - case TEXT_INPUT_PREEDIT_STYLE_UNDERLINE: + case WL_TEXT_INPUT_PREEDIT_STYLE_DEFAULT: + case WL_TEXT_INPUT_PREEDIT_STYLE_UNDERLINE: attr1 = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE); break; - case TEXT_INPUT_PREEDIT_STYLE_INCORRECT: + case WL_TEXT_INPUT_PREEDIT_STYLE_INCORRECT: attr1 = pango_attr_underline_new(PANGO_UNDERLINE_ERROR); attr2 = pango_attr_underline_color_new(65535, 0, 0); break; - case TEXT_INPUT_PREEDIT_STYLE_SELECTION: + case WL_TEXT_INPUT_PREEDIT_STYLE_SELECTION: attr1 = pango_attr_background_new(0.3 * 65535, 0.3 * 65535, 65535); attr2 = pango_attr_foreground_new(65535, 65535, 65535); break; - case TEXT_INPUT_PREEDIT_STYLE_HIGHLIGHT: - case TEXT_INPUT_PREEDIT_STYLE_ACTIVE: + case WL_TEXT_INPUT_PREEDIT_STYLE_HIGHLIGHT: + case WL_TEXT_INPUT_PREEDIT_STYLE_ACTIVE: attr1 = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE); attr2 = pango_attr_weight_new(PANGO_WEIGHT_BOLD); break; - case TEXT_INPUT_PREEDIT_STYLE_INACTIVE: + case WL_TEXT_INPUT_PREEDIT_STYLE_INACTIVE: attr1 = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE); attr2 = pango_attr_foreground_new(0.3 * 65535, 0.3 * 65535, 0.3 * 65535); break; @@ -291,7 +291,7 @@ text_input_preedit_styling(void *data, static void text_input_preedit_cursor(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, int32_t index) { struct text_entry *entry = data; @@ -301,7 +301,7 @@ text_input_preedit_cursor(void *data, static void text_input_modifiers_map(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, struct wl_array *map) { struct text_entry *entry = data; @@ -311,7 +311,7 @@ text_input_modifiers_map(void *data, static void text_input_keysym(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t serial, uint32_t time, uint32_t key, @@ -383,7 +383,7 @@ text_input_keysym(void *data, static void text_input_enter(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, struct wl_surface *surface) { struct text_entry *entry = data; @@ -401,7 +401,7 @@ text_input_enter(void *data, static void text_input_leave(void *data, - struct text_input *text_input) + struct wl_text_input *text_input) { struct text_entry *entry = data; @@ -409,21 +409,21 @@ text_input_leave(void *data, entry->active = 0; - text_input_hide_input_panel(text_input); + wl_text_input_hide_input_panel(text_input); widget_schedule_redraw(entry->widget); } static void text_input_input_panel_state(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t state) { } static void text_input_language(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t serial, const char *language) { @@ -432,7 +432,7 @@ text_input_language(void *data, static void text_input_text_direction(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t serial, uint32_t direction) { @@ -442,21 +442,21 @@ text_input_text_direction(void *data, switch (direction) { - case TEXT_INPUT_TEXT_DIRECTION_LTR: + case WL_TEXT_INPUT_TEXT_DIRECTION_LTR: pango_direction = PANGO_DIRECTION_LTR; break; - case TEXT_INPUT_TEXT_DIRECTION_RTL: + case WL_TEXT_INPUT_TEXT_DIRECTION_RTL: pango_direction = PANGO_DIRECTION_RTL; break; - case TEXT_INPUT_TEXT_DIRECTION_AUTO: + case WL_TEXT_INPUT_TEXT_DIRECTION_AUTO: default: pango_direction = PANGO_DIRECTION_NEUTRAL; } - + pango_context_set_base_dir(context, pango_direction); } -static const struct text_input_listener text_input_listener = { +static const struct wl_text_input_listener text_input_listener = { text_input_enter, text_input_leave, text_input_modifiers_map, @@ -485,8 +485,8 @@ text_entry_create(struct editor *editor, const char *text) entry->active = 0; entry->cursor = strlen(text); entry->anchor = entry->cursor; - entry->text_input = text_input_manager_create_text_input(editor->text_input_manager); - text_input_add_listener(entry->text_input, &text_input_listener, entry); + entry->text_input = wl_text_input_manager_create_text_input(editor->text_input_manager); + wl_text_input_add_listener(entry->text_input, &text_input_listener, entry); widget_set_redraw_handler(entry->widget, text_entry_redraw_handler); widget_set_button_handler(entry->widget, text_entry_button_handler); @@ -498,7 +498,7 @@ static void text_entry_destroy(struct text_entry *entry) { widget_destroy(entry->widget); - text_input_destroy(entry->text_input); + wl_text_input_destroy(entry->text_input); g_clear_object(&entry->layout); free(entry->text); free(entry); @@ -566,25 +566,25 @@ text_entry_activate(struct text_entry *entry, struct wl_surface *surface = window_get_wl_surface(entry->window); if (entry->click_to_show && entry->active) { - text_input_show_input_panel(entry->text_input); + wl_text_input_show_input_panel(entry->text_input); return; } if (!entry->click_to_show) - text_input_show_input_panel(entry->text_input); + wl_text_input_show_input_panel(entry->text_input); - text_input_activate(entry->text_input, - seat, - surface); + wl_text_input_activate(entry->text_input, + seat, + surface); } static void text_entry_deactivate(struct text_entry *entry, struct wl_seat *seat) { - text_input_deactivate(entry->text_input, - seat); + wl_text_input_deactivate(entry->text_input, + seat); } static void @@ -593,7 +593,7 @@ text_entry_update_layout(struct text_entry *entry) char *text; PangoAttrList *attr_list; - assert(((unsigned int)entry->cursor) <= strlen(entry->text) + + assert((entry->cursor) <= strlen(entry->text) + (entry->preedit.text ? strlen(entry->preedit.text) : 0)); if (entry->preedit.text) { @@ -655,24 +655,24 @@ text_entry_update(struct text_entry *entry) { struct rectangle cursor_rectangle; - text_input_set_content_type(entry->text_input, - TEXT_INPUT_CONTENT_HINT_NONE, - entry->content_purpose); + wl_text_input_set_content_type(entry->text_input, + WL_TEXT_INPUT_CONTENT_HINT_NONE, + entry->content_purpose); - text_input_set_surrounding_text(entry->text_input, - entry->text, - entry->cursor, - entry->anchor); + wl_text_input_set_surrounding_text(entry->text_input, + entry->text, + entry->cursor, + entry->anchor); if (entry->preferred_language) - text_input_set_preferred_language(entry->text_input, - entry->preferred_language); + wl_text_input_set_preferred_language(entry->text_input, + entry->preferred_language); text_entry_get_cursor_rectangle(entry, &cursor_rectangle); - text_input_set_cursor_rectangle(entry->text_input, cursor_rectangle.x, cursor_rectangle.y, - cursor_rectangle.width, cursor_rectangle.height); + wl_text_input_set_cursor_rectangle(entry->text_input, cursor_rectangle.x, cursor_rectangle.y, + cursor_rectangle.width, cursor_rectangle.height); - text_input_commit_state(entry->text_input, ++entry->serial); + wl_text_input_commit_state(entry->text_input, ++entry->serial); } static void @@ -733,7 +733,7 @@ text_entry_commit_and_reset(struct text_entry *entry) free(commit); } - text_input_reset(entry->text_input); + wl_text_input_reset(entry->text_input); text_entry_update(entry); entry->reset_serial = entry->serial; } @@ -779,9 +779,9 @@ text_entry_try_invoke_preedit_action(struct text_entry *entry, } if (state == WL_POINTER_BUTTON_STATE_RELEASED) - text_input_invoke_action(entry->text_input, - button, - cursor - entry->cursor); + wl_text_input_invoke_action(entry->text_input, + button, + cursor - entry->cursor); return 1; } @@ -1134,10 +1134,10 @@ global_handler(struct display *display, uint32_t name, { struct editor *editor = data; - if (!strcmp(interface, "text_input_manager")) { + if (!strcmp(interface, "wl_text_input_manager")) { editor->text_input_manager = display_bind(display, name, - &text_input_manager_interface, 1); + &wl_text_input_manager_interface, 1); } } @@ -1183,7 +1183,7 @@ main(int argc, char *argv[]) if (preferred_language) editor.entry->preferred_language = strdup(preferred_language); editor.editor = text_entry_create(&editor, "Numeric"); - editor.editor->content_purpose = TEXT_INPUT_CONTENT_PURPOSE_NUMBER; + editor.editor->content_purpose = WL_TEXT_INPUT_CONTENT_PURPOSE_NUMBER; editor.editor->click_to_show = click_to_show; window_set_title(editor.window, "Text Editor"); diff --git a/clients/keyboard.c b/clients/keyboard.c index 4fc8e73..6c5ddd7 100644 --- a/clients/keyboard.c +++ b/clients/keyboard.c @@ -212,7 +212,7 @@ static const struct layout normal_layout = { 12, 4, "en", - TEXT_INPUT_TEXT_DIRECTION_LTR + WL_TEXT_INPUT_TEXT_DIRECTION_LTR }; static const struct layout numeric_layout = { @@ -221,7 +221,7 @@ static const struct layout numeric_layout = { 12, 2, "en", - TEXT_INPUT_TEXT_DIRECTION_LTR + WL_TEXT_INPUT_TEXT_DIRECTION_LTR }; static const struct layout arabic_layout = { @@ -230,7 +230,7 @@ static const struct layout arabic_layout = { 13, 4, "ar", - TEXT_INPUT_TEXT_DIRECTION_RTL + WL_TEXT_INPUT_TEXT_DIRECTION_RTL }; static const char *style_labels[] = { @@ -315,8 +315,8 @@ static const struct layout * get_current_layout(struct virtual_keyboard *keyboard) { switch (keyboard->content_purpose) { - case TEXT_INPUT_CONTENT_PURPOSE_DIGITS: - case TEXT_INPUT_CONTENT_PURPOSE_NUMBER: + case WL_TEXT_INPUT_CONTENT_PURPOSE_DIGITS: + case WL_TEXT_INPUT_CONTENT_PURPOSE_NUMBER: return &numeric_layout; default: if (keyboard->preferred_language && diff --git a/protocol/text.xml b/protocol/text.xml index 58a6ab5..508c315 100644 --- a/protocol/text.xml +++ b/protocol/text.xml @@ -26,11 +26,11 @@ THIS SOFTWARE. - + An object used for text input. Adds support for text input and input methods to applications. A text-input object is created from a - text_input_manager and corresponds typically to a text entry in an + wl_text_input_manager and corresponds typically to a text entry in an application. Requests are used to activate/deactivate the text-input object and set state information like surrounding and selected text or the content type. @@ -318,7 +318,7 @@ - + A factory for text-input objects. This object is a global singleton. @@ -326,7 +326,7 @@ Creates a new text-input object. - + diff --git a/src/text-backend.c b/src/text-backend.c index 39439dd..2c450b3 100644 --- a/src/text-backend.c +++ b/src/text-backend.c @@ -120,7 +120,7 @@ deactivate_text_input(struct text_input *text_input, input_method->model = NULL; input_method->context = NULL; wl_signal_emit(&ec->hide_input_panel_signal, ec); - text_input_send_leave(&text_input->resource); + wl_text_input_send_leave(&text_input->resource); } } @@ -190,7 +190,7 @@ text_input_activate(struct wl_client *client, wl_signal_emit(&ec->update_input_panel_signal, &text_input->cursor_rectangle); } - 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 @@ -329,7 +329,7 @@ text_input_set_preferred_language(struct wl_client *client, } } -static const struct text_input_interface text_input_implementation = { +static const struct wl_text_input_interface text_input_implementation = { text_input_activate, text_input_deactivate, text_input_show_input_panel, @@ -353,7 +353,7 @@ static void text_input_manager_create_text_input(struct wl_client *client, text_input = calloc(1, sizeof *text_input); text_input->resource.object.id = id; - text_input->resource.object.interface = &text_input_interface; + text_input->resource.object.interface = &wl_text_input_interface; text_input->resource.object.implementation = (void (**)(void)) &text_input_implementation; @@ -367,7 +367,7 @@ static void text_input_manager_create_text_input(struct wl_client *client, wl_client_add_resource(client, &text_input->resource); }; -static const struct text_input_manager_interface text_input_manager_implementation = { +static const struct wl_text_input_manager_interface text_input_manager_implementation = { text_input_manager_create_text_input }; @@ -381,7 +381,7 @@ bind_text_input_manager(struct wl_client *client, /* No checking for duplicate binding necessary. * No events have to be sent, so we don't need the return value. */ - wl_client_add_object(client, &text_input_manager_interface, + wl_client_add_object(client, &wl_text_input_manager_interface, &text_input_manager_implementation, id, text_input_manager); } @@ -409,7 +409,7 @@ text_input_manager_create(struct weston_compositor *ec) text_input_manager->text_input_manager_global = wl_display_add_global(ec->wl_display, - &text_input_manager_interface, + &wl_text_input_manager_interface, text_input_manager, bind_text_input_manager); text_input_manager->destroy_listener.notify = text_input_manager_notifier_destroy; @@ -431,7 +431,7 @@ input_method_context_commit_string(struct wl_client *client, { struct input_method_context *context = resource->data; - text_input_send_commit_string(&context->model->resource, serial, text); + wl_text_input_send_commit_string(&context->model->resource, serial, text); } static void @@ -443,7 +443,7 @@ input_method_context_preedit_string(struct wl_client *client, { struct input_method_context *context = resource->data; - text_input_send_preedit_string(&context->model->resource, serial, text, commit); + wl_text_input_send_preedit_string(&context->model->resource, serial, text, commit); } static void @@ -455,7 +455,7 @@ input_method_context_preedit_styling(struct wl_client *client, { struct input_method_context *context = resource->data; - text_input_send_preedit_styling(&context->model->resource, index, length, style); + wl_text_input_send_preedit_styling(&context->model->resource, index, length, style); } static void @@ -465,7 +465,7 @@ input_method_context_preedit_cursor(struct wl_client *client, { struct input_method_context *context = resource->data; - text_input_send_preedit_cursor(&context->model->resource, cursor); + wl_text_input_send_preedit_cursor(&context->model->resource, cursor); } static void @@ -476,7 +476,7 @@ input_method_context_delete_surrounding_text(struct wl_client *client, { struct input_method_context *context = resource->data; - text_input_send_delete_surrounding_text(&context->model->resource, index, length); + wl_text_input_send_delete_surrounding_text(&context->model->resource, index, length); } static void @@ -487,7 +487,7 @@ input_method_context_cursor_position(struct wl_client *client, { struct input_method_context *context = resource->data; - text_input_send_cursor_position(&context->model->resource, index, anchor); + wl_text_input_send_cursor_position(&context->model->resource, index, anchor); } static void @@ -497,7 +497,7 @@ input_method_context_modifiers_map(struct wl_client *client, { struct input_method_context *context = resource->data; - text_input_send_modifiers_map(&context->model->resource, map); + wl_text_input_send_modifiers_map(&context->model->resource, map); } static void @@ -511,7 +511,7 @@ input_method_context_keysym(struct wl_client *client, { struct input_method_context *context = resource->data; - text_input_send_keysym(&context->model->resource, serial, time, + wl_text_input_send_keysym(&context->model->resource, serial, time, sym, state, modifiers); } @@ -635,7 +635,7 @@ input_method_context_language(struct wl_client *client, { struct input_method_context *context = resource->data; - text_input_send_language(&context->model->resource, serial, language); + wl_text_input_send_language(&context->model->resource, serial, language); } static void @@ -646,7 +646,7 @@ input_method_context_text_direction(struct wl_client *client, { struct input_method_context *context = resource->data; - text_input_send_text_direction(&context->model->resource, serial, direction); + wl_text_input_send_text_direction(&context->model->resource, serial, direction); } diff --git a/tests/text-test.c b/tests/text-test.c index d8ffc38..48f2b5a 100644 --- a/tests/text-test.c +++ b/tests/text-test.c @@ -33,7 +33,7 @@ struct text_input_state { static void text_input_commit_string(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t serial, const char *text) { @@ -41,7 +41,7 @@ text_input_commit_string(void *data, static void text_input_preedit_string(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t serial, const char *text, const char *commit) @@ -50,7 +50,7 @@ text_input_preedit_string(void *data, static void text_input_delete_surrounding_text(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, int32_t index, uint32_t length) { @@ -58,7 +58,7 @@ text_input_delete_surrounding_text(void *data, static void text_input_cursor_position(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, int32_t index, int32_t anchor) { @@ -66,7 +66,7 @@ text_input_cursor_position(void *data, static void text_input_preedit_styling(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t index, uint32_t length, uint32_t style) @@ -75,21 +75,21 @@ text_input_preedit_styling(void *data, static void text_input_preedit_cursor(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, int32_t index) { } static void text_input_modifiers_map(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, struct wl_array *map) { } static void text_input_keysym(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t serial, uint32_t time, uint32_t sym, @@ -100,7 +100,7 @@ text_input_keysym(void *data, static void text_input_enter(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, struct wl_surface *surface) { @@ -113,7 +113,7 @@ text_input_enter(void *data, static void text_input_leave(void *data, - struct text_input *text_input) + struct wl_text_input *text_input) { struct text_input_state *state = data; @@ -122,14 +122,14 @@ text_input_leave(void *data, static void text_input_input_panel_state(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t state) { } static void text_input_language(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t serial, const char *language) { @@ -137,13 +137,13 @@ text_input_language(void *data, static void text_input_text_direction(void *data, - struct text_input *text_input, + struct wl_text_input *text_input, uint32_t serial, uint32_t direction) { } -static const struct text_input_listener text_input_listener = { +static const struct wl_text_input_listener text_input_listener = { text_input_enter, text_input_leave, text_input_modifiers_map, @@ -163,8 +163,8 @@ TEST(text_test) { struct client *client; struct global *global; - struct text_input_manager *factory; - struct text_input *text_input; + struct wl_text_input_manager *factory; + struct wl_text_input *text_input; struct text_input_state state; client = client_create(100, 100, 100, 100); @@ -172,17 +172,17 @@ TEST(text_test) factory = NULL; wl_list_for_each(global, &client->global_list, link) { - if (strcmp(global->interface, "text_input_manager") == 0) + if (strcmp(global->interface, "wl_text_input_manager") == 0) factory = wl_registry_bind(client->wl_registry, global->name, - &text_input_manager_interface, 1); + &wl_text_input_manager_interface, 1); } assert(factory); memset(&state, 0, sizeof state); - text_input = text_input_manager_create_text_input(factory); - text_input_add_listener(text_input, &text_input_listener, &state); + text_input = wl_text_input_manager_create_text_input(factory); + wl_text_input_add_listener(text_input, &text_input_listener, &state); /* Make sure our test surface has keyboard focus. */ wl_test_activate_surface(client->test->wl_test, @@ -191,19 +191,19 @@ TEST(text_test) assert(client->input->keyboard->focus == client->surface); /* Activate test model and make sure we get enter event. */ - text_input_activate(text_input, client->input->wl_seat, - client->surface->wl_surface); + wl_text_input_activate(text_input, client->input->wl_seat, + client->surface->wl_surface); client_roundtrip(client); assert(state.activated == 1 && state.deactivated == 0); /* Deactivate test model and make sure we get leave event. */ - text_input_deactivate(text_input, client->input->wl_seat); + wl_text_input_deactivate(text_input, client->input->wl_seat); client_roundtrip(client); assert(state.activated == 1 && state.deactivated == 1); /* Activate test model again. */ - text_input_activate(text_input, client->input->wl_seat, - client->surface->wl_surface); + wl_text_input_activate(text_input, client->input->wl_seat, + client->surface->wl_surface); client_roundtrip(client); assert(state.activated == 2 && state.deactivated == 1); -- 2.7.4