static E_Input_Method *g_input_method = NULL;
static E_Text_Input *g_text_input = NULL;
static struct wl_client *g_client = NULL;
-static struct wl_client *g_focused_client = NULL;
static Eina_List *shutdown_list = NULL;
static Eina_Bool g_disable_show_panel = EINA_FALSE;
static Eeze_Udev_Watch *eeze_udev_watch_hander = NULL;
Because input_panel_hide event can be called after focus_out(deactivate) by application.
And Input Method(IME) should know the state of their own input_panel to manage their resource when the input_panel is hidden.
*/
- if (input_method &&
+ if (input_method &&
((!input_method->context) || (!input_method->context->resource)))
_context_created = _e_text_input_method_create_context(client, input_method, text_input, EINA_FALSE);
return;
}
- struct wl_resource *text_input_resource = NULL;
- Eina_Bool resource_created = EINA_FALSE;
-
if ((context->input) && (context->input->resource))
- text_input_resource = context->input->resource;
-
- if (!text_input_resource)
- {
- LOGD("Create text input resource...\n");
- if (g_focused_client)
- {
- text_input_resource = wl_resource_create(g_focused_client, &wl_text_input_interface, 1, 0);
-
- if (text_input_resource)
- resource_created = EINA_TRUE;
- }
- }
-
- if (text_input_resource)
- {
- wl_text_input_send_keysym(text_input_resource,
- serial, time, sym, state, modifiers);
-
- if (resource_created)
- wl_resource_destroy(text_input_resource);
- }
+ wl_text_input_send_keysym(context->input->resource,
+ serial, time, sym, state, modifiers);
}
#if ENABLE_GRAB_KEYBOARD
static void
_e_text_input_deactivate(E_Text_Input *text_input, E_Input_Method *input_method, Eina_Bool need_focus_in)
{
- LOGD("text_input : %p, input_method : %p\n", text_input, input_method);
-
if (text_input == g_text_input)
{
g_text_input = NULL;
ecore_key_down_handler = NULL;
}
+ input_method->input = NULL;
+ if (input_method->context) input_method->context->input = NULL;
+ input_method->context = NULL;
+
+ text_input->input_methods = eina_list_remove(text_input->input_methods, input_method);
+
if (text_input->resource)
wl_text_input_send_leave(text_input->resource);
E_Text_Input *text_input = NULL;
E_Input_Method *input_method = NULL;
E_Text_Input *old = NULL;
+ E_Input_Method_Context *context = NULL;
EINA_SAFETY_ON_NULL_GOTO(resource, err);
EINA_SAFETY_ON_NULL_GOTO(seat, err);
EINA_SAFETY_ON_TRUE_GOTO(e_object_is_del(E_OBJECT(ec)), err);
client_surface_ec = ec;
+ text_input = wl_resource_get_user_data(resource);
+ g_text_input = text_input;
+ g_client = client;
+
/* FIXME: should get input_method object from seat. */
input_method = wl_resource_get_user_data(g_input_method->resource);
- LOGD("resource : %p, inputmethod : %p\n", g_input_method->resource, input_method);
EINA_SAFETY_ON_NULL_GOTO(input_method, err);
- text_input = wl_resource_get_user_data(resource);
- LOGD("client : %p, text_input : %p, input_method : %p\n", client, text_input, input_method);
-
old = input_method->input;
if (old == text_input)
return;
}
}
- if (!_e_text_input_method_create_context(client, input_method, text_input, EINA_TRUE))
- return;
+ input_method->input = text_input;
+ text_input->input_methods = eina_list_append(text_input->input_methods, input_method);
+
+ if (input_method->resource)
+ {
+ if (!(context = E_NEW(E_Input_Method_Context, 1)))
+ {
+ wl_client_post_no_memory(client);
+ ERR("Could not allocate space for Input_Method_Context");
+ return;
+ }
+
+ if (!ecore_key_down_handler)
+ ecore_key_down_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
+ _e_mod_ecore_key_down_cb,
+ NULL);
+
+ context->resource =
+ wl_resource_create(wl_resource_get_client(input_method->resource),
+ &wl_input_method_context_interface, 1, 0);
+
- g_focused_client = client;
+ if (context->resource)
+ wl_resource_set_implementation(context->resource,
+ &_e_text_input_method_context_implementation,
+ context, _e_text_input_method_context_cb_resource_destroy);
+
+ context->input = text_input;
+ context->input_method = input_method;
+ input_method->context = context;
+
+ if (context->resource)
+ wl_input_method_send_activate(input_method->resource, context->resource, text_input->id, EINA_TRUE);
+ }
- if (!ecore_key_down_handler)
- ecore_key_down_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
- _e_mod_ecore_key_down_cb,
- NULL);
#ifdef _TV
set_soft_keyboard_mode();
#endif
g_text_input = text_input;
g_client = client;
input_method->input = text_input;
-
- if (!text_input->input_methods)
- text_input->input_methods = eina_list_append(text_input->input_methods, input_method);
+ text_input->input_methods = eina_list_append(text_input->input_methods, input_method);
if (!(context = E_NEW(E_Input_Method_Context, 1)))
{
E_Text_Input *text_input = wl_resource_get_user_data(resource);
E_Input_Method *input_method = NULL;
- LOGD("text input : %p\n", text_input);
-
if (!text_input)
{
WTI_WARNING(resource,
EINA_LIST_FREE(text_input->input_methods, input_method)
{
- LOGD("destroy input method : %p\n", input_method);
_e_text_input_deactivate(text_input, input_method, EINA_TRUE);
-
- if (input_method->input == text_input)
- {
- input_method->input = NULL;
- if (input_method->context) input_method->context->input = NULL;
- input_method->context = NULL;
- text_input->input_methods = eina_list_remove(text_input->input_methods, input_method);
- }
}
free(text_input);
static void
_e_text_input_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
{
- E_Text_Input *text_input = wl_resource_get_user_data(resource);
- LOGD("client : %p, text input : %p\n", client, text_input);
-
- if (g_focused_client == client)
- g_focused_client = NULL;
-
wl_resource_destroy(resource);
}