} events;
};
+struct ds_tizen_input_method_manager {
+ struct wl_global *global;
+ struct wl_resource *resource;
+
+ struct wl_listener destroy;
+
+ struct {
+ struct wl_signal destroy;
+ struct wl_signal set_transient_for;
+ } events;
+};
+
static const struct zwp_input_method_context_v1_interface context_impl;
+static const struct zwp_input_method_manager_v1_interface input_method_mgr_impl;
+
+WL_EXPORT void
+ds_tizen_input_method_manager_add_destroy_listener(
+ struct ds_tizen_input_method_manager *im_mgr, struct wl_listener *listener)
+{
+ wl_signal_add(&im_mgr->events.destroy, listener);
+}
+
+WL_EXPORT void
+ds_tizen_input_method_manager_add_set_transient_for_listener(
+ struct ds_tizen_input_method_manager *im_mgr, struct wl_listener *listener)
+{
+ wl_signal_add(&im_mgr->events.set_transient_for, listener);
+}
+
+static void
+input_method_mgr_handle_display_destroy(struct wl_listener *listener, void *data)
+{
+ struct ds_tizen_input_method_manager *input_method_mgr;
+
+ input_method_mgr = wl_container_of(listener, input_method_mgr, destroy);
+
+ ds_inf("Global destroy: input_method_mgr(%p)", input_method_mgr);
+
+ wl_signal_emit(&input_method_mgr->events.destroy, input_method_mgr);
+ wl_list_remove(&input_method_mgr->destroy.link);
+
+ wl_global_destroy(input_method_mgr->global);
+ free(input_method_mgr);
+}
+
+static void
+input_method_mgr_handle_set_transient_for(struct wl_client *wl_client,
+ struct wl_resource *resource, uint32_t parent_pid, uint32_t child_pid)
+{
+ struct ds_tizen_input_method_manager_event_set_transient_for ds_event;
+ struct ds_tizen_input_method_manager *input_method_mgr;
+
+ input_method_mgr = wl_resource_get_user_data(resource);
+
+ ds_inf("input_method_mgr_handle_set_transient_for() parent:%u, child:%u",
+ parent_pid, child_pid);
+
+ ds_event.pid_parent = parent_pid;
+ ds_event.pid_child = child_pid;
+ wl_signal_emit(&input_method_mgr->events.set_transient_for, &ds_event);
+}
+
+static const struct zwp_input_method_manager_v1_interface input_method_mgr_impl =
+{
+ .set_transient_for = input_method_mgr_handle_set_transient_for,
+};
+
+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,
+ &zwp_input_method_manager_v1_interface,
+ version, id);
+ if (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_EXPORT struct ds_tizen_input_method_manager *
+ds_tizen_input_method_manager_create(struct wl_display *display)
+{
+ struct ds_tizen_input_method_manager *input_method_mgr;
+
+ input_method_mgr = calloc(1, sizeof *input_method_mgr);
+ if (input_method_mgr == NULL) {
+ ds_err("calloc() failed. ds_tizen_input_method_manager");
+ return NULL;
+ }
+
+ input_method_mgr->global = wl_global_create(display,
+ &zwp_input_method_manager_v1_interface, INPUT_METHOD_VERSION, input_method_mgr, input_method_mgr_bind);
+ if (!input_method_mgr->global) {
+ free(input_method_mgr);
+ return NULL;
+ }
+
+ wl_signal_init(&input_method_mgr->events.destroy);
+ wl_signal_init(&input_method_mgr->events.set_transient_for);
+
+ input_method_mgr->destroy.notify = input_method_mgr_handle_display_destroy;
+ wl_display_add_destroy_listener(display, &input_method_mgr->destroy);
+
+ ds_inf("Global create: zwp_input_method_manager_v1. input_method_mgr(%p)", input_method_mgr);
+
+ return input_method_mgr;
+}
WL_EXPORT void
ds_tizen_input_method_add_destroy_listener(