struct wl_listener destroy;
struct wl_listener mgr_destroy;
-
- struct wl_listener new_im_context;
};
struct tinyds_input_method_context {
static bool add_new_text_input(struct tinyds_server *server);
static bool add_new_input_method(struct tinyds_server *server);
+static bool add_new_input_method_context(
+ struct tinyds_input_method *input_method,
+ struct tinyds_text_input *text_input);
static void text_input_mgr_handle_destroy(struct wl_listener *listener,
void *data TINYDS_UNUSED);
static void input_method_handle_destroy(struct wl_listener *listener,
void *data TINYDS_UNUSED);
-static void input_method_handle_new_im_context(struct wl_listener *listener,
- void *data TINYDS_UNUSED);
int
main(void)
wl_event_loop_add_idle(ev, output_schedule_commit_handle_idle_timer, output);
}
-static bool
-add_new_text_input(struct tinyds_server *server)
-{
- struct tinyds_text_input *text_input;
-
- text_input = calloc(1, sizeof *text_input);
- if (!text_input)
- return false;
-
- text_input->text_input_mgr = ds_tizen_text_input_manager_create(server->display);
- if (!text_input->text_input_mgr) {
- free(text_input);
- ds_err("Could not create ds_tizen_text_input_manager");
- return false;
- }
-
- wl_list_init(&text_input->input_methods);
-
- text_input->destroy.notify = text_input_mgr_handle_destroy;
- ds_tizen_text_input_manager_add_destroy_listener(text_input->text_input_mgr,
- &text_input->destroy);
-
- text_input->new_text_input.notify = text_input_mgr_handle_new_text_input;
- ds_tizen_text_input_manager_add_new_text_input_listener(text_input->text_input_mgr,
- &text_input->new_text_input);
-
- text_input->server = server;
- server->text_input = text_input;
-
- ds_inf("Text_Input (%p) added", text_input);
-
- return true;
-}
-
-static bool
-add_new_input_method(struct tinyds_server *server)
-{
- struct tinyds_input_method *input_method;
-
- input_method = calloc(1, sizeof *input_method);
- if (!input_method)
- return false;
-
- input_method->input_method = ds_tizen_input_method_create(server->display);
- if (!input_method->input_method) {
- free(input_method);
- ds_err("Could not create ds_tizen_input_method");
- return false;
- }
- input_method->destroy.notify = input_method_handle_destroy;
- ds_tizen_input_method_add_destroy_listener(input_method->input_method,
- &input_method->destroy);
-
- input_method->input_method_mgr = ds_tizen_input_method_manager_create(server->display);
- if (!input_method->input_method_mgr) {
- free(input_method);
- ds_err("Could not create ds_tizen_input_method_manager");
- return false;
- }
-
- input_method->mgr_destroy.notify = input_method_mgr_handle_destroy;
- ds_tizen_input_method_manager_add_destroy_listener(input_method->input_method_mgr,
- &input_method->mgr_destroy);
-
- input_method->new_im_context.notify = input_method_handle_new_im_context;
- ds_tizen_input_method_add_new_input_method_context_listener(input_method->input_method,
- &input_method->new_im_context);
-
- input_method->server = server;
- server->input_method = input_method;
-
- ds_inf("Input_Method (%p) added", input_method);
-
- return true;
-}
-
static void
text_input_mgr_handle_destroy(struct wl_listener *listener, void *data)
{
text_input_handle_destroy(struct wl_listener *listener, void *data)
{
struct tinyds_text_input *text_input;
-
+
ds_inf("text_input_handle_destroy");
text_input = wl_container_of(listener, text_input, destroy);
{
struct tinyds_text_input *text_input;
struct tinyds_input_method *input_method;
- struct tinyds_input_method_context *context;
struct ds_tizen_text_input_event_activate *event = data;
text_input = wl_container_of(listener, text_input, text_input_activate);
text_input->surface = event->surface;
- context = calloc(1, sizeof *context);
- if (context == NULL)
- {
- ds_err("calloc is failed. tinyds_input_method_context");
+ if (!add_new_input_method_context(input_method, text_input))
return;
- }
- input_method->context = context;
- context->server = text_input->server;
- context->context = ds_tizen_input_method_create_context(input_method->input_method);
- context->input = text_input;
- context->input_method = input_method;
// ds_tizen_input_method_send_set_text_input_id();
}
input_method = wl_container_of(listener, input_method, destroy);
wl_list_remove(&input_method->destroy.link);
- wl_list_remove(&input_method->new_im_context.link);
server = input_method->server;
server->input_method = NULL;
ds_tizen_text_input_send_text_direction(text_input->input, event->serial, event->direction);
}
-static void
-input_method_handle_new_im_context(struct wl_listener *listener, void *data)
+static bool
+add_new_text_input(struct tinyds_server *server)
+{
+ struct tinyds_text_input *text_input;
+
+ text_input = calloc(1, sizeof *text_input);
+ if (!text_input)
+ return false;
+
+ text_input->text_input_mgr = ds_tizen_text_input_manager_create(server->display);
+ if (!text_input->text_input_mgr) {
+ free(text_input);
+ ds_err("Could not create ds_tizen_text_input_manager");
+ return false;
+ }
+
+ wl_list_init(&text_input->input_methods);
+
+ text_input->destroy.notify = text_input_mgr_handle_destroy;
+ ds_tizen_text_input_manager_add_destroy_listener(text_input->text_input_mgr,
+ &text_input->destroy);
+
+ text_input->new_text_input.notify = text_input_mgr_handle_new_text_input;
+ ds_tizen_text_input_manager_add_new_text_input_listener(text_input->text_input_mgr,
+ &text_input->new_text_input);
+
+ text_input->server = server;
+ server->text_input = text_input;
+
+ ds_inf("Text_Input (%p) added", text_input);
+
+ return true;
+}
+
+static bool
+add_new_input_method(struct tinyds_server *server)
{
- struct ds_tizen_input_method_context *context = data;
struct tinyds_input_method *input_method;
- struct tinyds_input_method_context *ctx;
- ds_inf("input_method_handle_new_im_context");
+ input_method = calloc(1, sizeof *input_method);
+ if (!input_method)
+ return false;
+
+ input_method->input_method = ds_tizen_input_method_create(server->display);
+ if (!input_method->input_method) {
+ free(input_method);
+ ds_err("Could not create ds_tizen_input_method");
+ return false;
+ }
+ input_method->destroy.notify = input_method_handle_destroy;
+ ds_tizen_input_method_add_destroy_listener(input_method->input_method,
+ &input_method->destroy);
+
+ input_method->input_method_mgr = ds_tizen_input_method_manager_create(server->display);
+ if (!input_method->input_method_mgr) {
+ free(input_method);
+ ds_err("Could not create ds_tizen_input_method_manager");
+ return false;
+ }
- input_method = wl_container_of(listener, input_method, new_im_context);
- ctx = input_method->context;
+ input_method->mgr_destroy.notify = input_method_mgr_handle_destroy;
+ ds_tizen_input_method_manager_add_destroy_listener(input_method->input_method_mgr,
+ &input_method->mgr_destroy);
- ctx->destroy.notify = context_handle_destroy;
- ds_tizen_input_method_context_add_destroy_listener(context,
- &ctx->destroy);
+ input_method->server = server;
+ server->input_method = input_method;
- ctx->im_context_commit_string.notify = context_handle_commit_string;
- ds_tizen_input_method_context_add_commit_string_listener(context,
- &ctx->im_context_commit_string);
+ ds_inf("Input_Method (%p) added", input_method);
- ctx->im_context_preedit_string.notify = context_handle_preedit_string;
- ds_tizen_input_method_context_add_preedit_string_listener(context,
- &ctx->im_context_preedit_string);
+ return true;
+}
- ctx->im_context_preedit_styling.notify = context_handle_preedit_styling;
- ds_tizen_input_method_context_add_preedit_styling_listener(context,
- &ctx->im_context_preedit_styling);
+static bool
+add_new_input_method_context(struct tinyds_input_method *input_method,
+ struct tinyds_text_input *text_input)
+{
+ struct tinyds_input_method_context *context;
- ctx->im_context_preedit_cursor.notify = context_handle_preedit_cursor;
- ds_tizen_input_method_context_add_preedit_cursor_listener(context,
- &ctx->im_context_preedit_cursor);
+ context = calloc(1, sizeof *context);
+ if (context == NULL)
+ {
+ ds_err("calloc is failed. tinyds_input_method_context");
+ return false;
+ }
+ input_method->context = context;
+ context->input_method = input_method;
+ context->server = input_method->server;
+ context->input = text_input;
+
+ context->context = ds_tizen_input_method_create_context(input_method->input_method);
+
+ context->destroy.notify = context_handle_destroy;
+ ds_tizen_input_method_context_add_destroy_listener(context->context,
+ &context->destroy);
+
+ context->im_context_commit_string.notify = context_handle_commit_string;
+ ds_tizen_input_method_context_add_commit_string_listener(context->context,
+ &context->im_context_commit_string);
- ctx->im_context_delete_surrounding_text.notify = context_handle_delete_surrounding_text;
- ds_tizen_input_method_context_add_delete_surrounding_text_listener(context,
- &ctx->im_context_delete_surrounding_text);
+ context->im_context_preedit_string.notify = context_handle_preedit_string;
+ ds_tizen_input_method_context_add_preedit_string_listener(context->context,
+ &context->im_context_preedit_string);
- ctx->im_context_cursor_position.notify = context_handle_cursor_position;
- ds_tizen_input_method_context_add_cursor_position_listener(context,
- &ctx->im_context_cursor_position);
+ context->im_context_preedit_styling.notify = context_handle_preedit_styling;
+ ds_tizen_input_method_context_add_preedit_styling_listener(context->context,
+ &context->im_context_preedit_styling);
- ctx->im_context_modifiers_map.notify = context_handle_modifiers_map;
- ds_tizen_input_method_context_add_modifiers_map_listener(context,
- &ctx->im_context_modifiers_map);
+ context->im_context_preedit_cursor.notify = context_handle_preedit_cursor;
+ ds_tizen_input_method_context_add_preedit_cursor_listener(context->context,
+ &context->im_context_preedit_cursor);
- ctx->im_context_keysym.notify = context_handle_keysym;
- ds_tizen_input_method_context_add_keysym_listener(context,
- &ctx->im_context_keysym);
+ context->im_context_delete_surrounding_text.notify = context_handle_delete_surrounding_text;
+ ds_tizen_input_method_context_add_delete_surrounding_text_listener(context->context,
+ &context->im_context_delete_surrounding_text);
- ctx->im_context_grab_keyboard.notify = context_handle_grab_keyboard;
- ds_tizen_input_method_context_add_grab_keyboard_listener(context,
- &ctx->im_context_grab_keyboard);
+ context->im_context_cursor_position.notify = context_handle_cursor_position;
+ ds_tizen_input_method_context_add_cursor_position_listener(context->context,
+ &context->im_context_cursor_position);
- ctx->im_context_key.notify = context_handle_key;
- ds_tizen_input_method_context_add_key_listener(context,
- &ctx->im_context_key);
+ context->im_context_modifiers_map.notify = context_handle_modifiers_map;
+ ds_tizen_input_method_context_add_modifiers_map_listener(context->context,
+ &context->im_context_modifiers_map);
- ctx->im_context_modifiers.notify = context_handle_modifiers;
- ds_tizen_input_method_context_add_modifiers_listener(context,
- &ctx->im_context_modifiers);
+ context->im_context_keysym.notify = context_handle_keysym;
+ ds_tizen_input_method_context_add_keysym_listener(context->context,
+ &context->im_context_keysym);
- ctx->im_context_language.notify = context_handle_language;
- ds_tizen_input_method_context_add_language_listener(context,
- &ctx->im_context_language);
+ context->im_context_grab_keyboard.notify = context_handle_grab_keyboard;
+ ds_tizen_input_method_context_add_grab_keyboard_listener(context->context,
+ &context->im_context_grab_keyboard);
- ctx->im_context_text_direction.notify = context_handle_text_direction;
- ds_tizen_input_method_context_add_text_direction_listener(context,
- &ctx->im_context_text_direction);
+ context->im_context_key.notify = context_handle_key;
+ ds_tizen_input_method_context_add_key_listener(context->context,
+ &context->im_context_key);
+
+ context->im_context_modifiers.notify = context_handle_modifiers;
+ ds_tizen_input_method_context_add_modifiers_listener(context->context,
+ &context->im_context_modifiers);
+
+ context->im_context_language.notify = context_handle_language;
+ ds_tizen_input_method_context_add_language_listener(context->context,
+ &context->im_context_language);
+
+ context->im_context_text_direction.notify = context_handle_text_direction;
+ ds_tizen_input_method_context_add_text_direction_listener(context->context,
+ &context->im_context_text_direction);
+
+ return true;
}
struct {
struct wl_signal destroy;
- struct wl_signal new_input_method_context;
} events;
};
};
static void
-input_method_mgr_client_handle_destroy(struct wl_resource *resource)
-{
- ds_inf("input_method_mgr_client_handle_destroy");
-}
-
-static void
input_method_mgr_bind(struct wl_client *wl_client, void *data,
uint32_t version, uint32_t id)
{
struct ds_tizen_input_method_manager *input_method_mgr = data;
- struct wl_resource *resource;
ds_inf("input_method_mgr. client binds. (client:%p)", wl_client);
- resource = wl_resource_create(wl_client,
+ input_method_mgr->resource = wl_resource_create(wl_client,
&zwp_input_method_manager_v1_interface,
version, id);
- if (resource == NULL) {
+ if (input_method_mgr->resource == NULL) {
ds_err("input_method_mgr. wl_resource_create() failed.");
wl_client_post_no_memory(wl_client);
return;
}
- wl_resource_set_implementation(resource, &input_method_mgr_impl,
- input_method_mgr, input_method_mgr_client_handle_destroy);
+ wl_resource_set_implementation(input_method_mgr->resource, &input_method_mgr_impl,
+ input_method_mgr, NULL);
}
WL_EXPORT struct ds_tizen_input_method_manager *
}
WL_EXPORT void
-ds_tizen_input_method_add_new_input_method_context_listener(
- struct ds_tizen_input_method *im, struct wl_listener *listener)
-{
- wl_signal_add(&im->events.new_input_method_context, listener);
-}
-
-WL_EXPORT void
ds_tizen_input_method_send_activate(struct ds_tizen_input_method *im,
struct ds_tizen_input_method_context *context)
{
if (!binding) return NULL;
context->resource = wl_resource_create(wl_resource_get_client(binding),
&zwp_input_method_context_v1_interface, INPUT_METHOD_VERSION, 0);
+ if (context->resource == NULL) {
+ ds_err("context. wl_resource_create() failed.");
+ return NULL;
+ }
wl_resource_set_implementation(context->resource, &context_impl,
context, input_method_context_client_handle_destroy);
wl_signal_init(&context->events.language);
wl_signal_init(&context->events.text_direction);
- wl_signal_emit(&input_method->events.new_input_method_context, context);
-
ds_tizen_input_method_send_activate(input_method, context);
input_method->context = context;
}
static void
-input_method_client_handle_destroy(struct wl_resource *resource)
-{
- ds_inf("input_method_client_handle_destroy");
-}
-
-static void
input_method_bind(struct wl_client *wl_client, void *data,
uint32_t version, uint32_t id)
{
return;
}
wl_resource_set_implementation(input_method->resource, NULL,
- input_method, input_method_client_handle_destroy);
+ input_method, NULL);
}
WL_EXPORT struct ds_tizen_input_method *
}
wl_signal_init(&input_method->events.destroy);
- wl_signal_init(&input_method->events.new_input_method_context);
input_method->destroy.notify = input_method_handle_display_destroy;
wl_display_add_destroy_listener(display, &input_method->destroy);