From: Jihoon Kim Date: Thu, 4 May 2023 09:54:40 +0000 (+0900) Subject: Process key down or up event in input thread X-Git-Tag: accepted/tizen/unified/20230706.152209~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af7c256b7d41dffbe447bacb840e33022577721c;p=platform%2Fcore%2Fuifw%2Fe-mod-tizen-wl-textinput.git Process key down or up event in input thread This reverts commit 6a366940a3b280407e7fde8b01049acf20659d84. Change-Id: I4959f83dd58fda43acfbad977fd8f6232dbfeabf --- diff --git a/src/e_mod_main.c b/src/e_mod_main.c index eb4d758..2534345 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -2,6 +2,9 @@ #include "e.h" #include "e_mod_main.h" #include "e_mod_input_method_manager.h" +#include "e_device.h" +#include "e_input_event.h" + #include #include #include @@ -11,6 +14,7 @@ #include #include #include +#include #ifdef LOG_TAG #undef LOG_TAG @@ -146,10 +150,10 @@ static struct wl_client *g_client = NULL; static Eina_List *shutdown_list = NULL; static Eina_Bool g_disable_show_panel = EINA_FALSE; static Eeze_Udev_Watch *eeze_udev_watch_handler = NULL; -static Ecore_Event_Handler *ecore_key_down_handler = NULL; +static E_Input_Event_Filter *e_input_key_down_filter = NULL; static Eina_List *handlers = NULL; static uint32_t g_text_input_count = 1; -static Ecore_Timer *g_timer_will_hide = NULL; +static gint g_timer_will_hide = 0; static enum _E_Input_Panel_State g_input_panel_state = E_INPUT_PANEL_STATE_DID_HIDE; static E_Client *client_surface_ec = NULL; static E_Text_Input *g_show_text_input = NULL; @@ -225,8 +229,8 @@ _e_text_input_send_input_panel_geometry(struct wl_resource *resource, int x, int wl_text_input_send_input_panel_geometry(resource, x, y, w, h); } -static Eina_Bool -_will_hide_timer_handler(void *data) +static gboolean +_will_hide_timer_handler(gpointer data) { INF("TIMED OUT while waiting for WILL_HIDE_ACK : %d", g_input_panel_state); if (g_input_panel_state == E_INPUT_PANEL_STATE_WILL_HIDE) @@ -236,9 +240,18 @@ _will_hide_timer_handler(void *data) g_input_panel_state = E_INPUT_PANEL_STATE_DID_HIDE; } - g_timer_will_hide = NULL; + g_timer_will_hide = 0; + + return FALSE; +} - return ECORE_CALLBACK_CANCEL; +static void _cancel_will_hide_timer() +{ + if (g_timer_will_hide > 0) + { + g_source_remove(g_timer_will_hide); + g_timer_will_hide = 0; + } } static void @@ -274,11 +287,7 @@ _input_panel_hide(struct wl_client *client, struct wl_resource *resource, Eina_B if (text_input->resource) wl_text_input_send_private_command(text_input->resource, 0, "CONFORMANT_RESET"); - if (g_timer_will_hide) - { - ecore_timer_del(g_timer_will_hide); - g_timer_will_hide = NULL; - } + _cancel_will_hide_timer(); zone = e_zone_current_get(); effect_run = e_input_panel_is_effect_running(); @@ -288,7 +297,8 @@ _input_panel_hide(struct wl_client *client, struct wl_resource *resource, Eina_B timeout = 0.0f; else timeout = WILL_HIDE_TIMER_INTERVAL; - g_timer_will_hide = ecore_timer_add(timeout, _will_hide_timer_handler, NULL); + + g_timer_will_hide = g_timeout_add(timeout*1000, _will_hide_timer_handler, NULL); } if (g_input_method && g_input_method->resource) @@ -308,7 +318,9 @@ _input_panel_hide(struct wl_client *client, struct wl_resource *resource, Eina_B if (_context_created) _e_text_input_deactivate(text_input, input_method, EINA_FALSE); + ecore_thread_main_loop_begin(); e_input_panel_wait_update_set(EINA_FALSE); + ecore_thread_main_loop_end(); /* When the input panel surface is hidden, the candidate will hide too */ g_show_state_candidate = EINA_FALSE; @@ -456,12 +468,13 @@ _e_text_input_method_context_grab_set(E_Input_Method_Context *context, Eina_Bool if (context->kbd.state) xkb_state_unref(context->kbd.state); context->kbd.keymap = xkb_map_ref(e_comp_wl->xkb.keymap); context->kbd.state = xkb_state_new(e_comp_wl->xkb.keymap); - E_LIST_HANDLER_APPEND(context->kbd.handlers, ECORE_EVENT_KEY_DOWN, - _e_text_input_method_context_ecore_cb_key_down, - context); - E_LIST_HANDLER_APPEND(context->kbd.handlers, ECORE_EVENT_KEY_UP, - _e_text_input_method_context_ecore_cb_key_up, - context); + + E_Input_Event_Source *input_event_source = e_input_event_source_get(); + if (input_event_source) + { + _key_down_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_DOWN, _e_text_input_method_context_ecore_cb_key_down, context); + _key_up_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_UP, _e_text_input_method_context_ecore_cb_key_up, context); + } e_comp_grab_input(0, 1); } @@ -469,6 +482,19 @@ _e_text_input_method_context_grab_set(E_Input_Method_Context *context, Eina_Bool { E_FREE_LIST(context->kbd.handlers, ecore_event_handler_del); + E_Input_Event_Source *input_event_source = e_input_event_source_get(); + if (input_event_source) + { + if (_key_down_handler) + e_input_event_handler_del(input_event_source, _key_down_handler); + + if (_key_up_handler) + e_input_event_handler_del(input_event_source, _key_up_handler); + + _key_down_handler = NULL; + _key_up_handler = NULL; + } + e_comp_ungrab_input(0, 1); if (context->kbd.keymap) @@ -636,7 +662,9 @@ feed_key_event(const char *keyname, const char *key, const char *string, int key e->same_screen = 1; e->keycode = keycode; - ecore_event_add(state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_keyevent_free, NULL); + E_Input_Event_Source *input_event_source = e_input_event_source_get(); + if (input_event_source) + e_input_event_add(input_event_source, state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_keyevent_free, NULL); } static void @@ -1012,7 +1040,7 @@ _e_text_input_method_context_cb_resource_destroy(struct wl_resource *resource) free(context); } -static Eina_Bool +static gboolean _e_mod_ecore_key_down_cb(void *data, int type, void *event) { Ecore_Event_Key *ev = (Ecore_Event_Key *)event; @@ -1025,9 +1053,11 @@ _e_mod_ecore_key_down_cb(void *data, int type, void *event) if (g_disable_show_panel == EINA_TRUE) return ECORE_CALLBACK_PASS_ON; + E_Device *dev = (E_Device *)ev->dev; + /* process remote controller key exceptionally */ - if (ecore_device_class_get(ev->dev) == ECORE_DEVICE_CLASS_KEYBOARD && - ecore_device_subclass_get(ev->dev) == ECORE_DEVICE_SUBCLASS_REMOCON) + if (e_device_class_get(dev) == ECORE_DEVICE_CLASS_KEYBOARD && + e_device_subclass_get(dev) == ECORE_DEVICE_SUBCLASS_REMOCON) return ECORE_CALLBACK_PASS_ON; /* process up/down/left/right and some keys exceptionally */ @@ -1096,10 +1126,11 @@ _e_text_input_deactivate(E_Text_Input *text_input, E_Input_Method *input_method, } } - if (ecore_key_down_handler) + if (e_input_key_down_filter) { - ecore_event_handler_del(ecore_key_down_handler); - ecore_key_down_handler = NULL; + E_Input_Event_Source *input_event_source = e_input_event_source_get(); + e_input_event_filter_del(input_event_source, e_input_key_down_filter); + e_input_key_down_filter = NULL; } LOGI("Resetting input_method->input : %p, text_input : %p, %p %p", @@ -1191,10 +1222,9 @@ _e_text_input_cb_activate(struct wl_client *client, struct wl_resource *resource if (input_method->resource) { - if (!ecore_key_down_handler) - ecore_key_down_handler = ecore_event_handler_prepend(ECORE_EVENT_KEY_DOWN, - _e_mod_ecore_key_down_cb, - NULL); + E_Input_Event_Source *input_event_source = e_input_event_source_get(); + if (!e_input_key_down_filter) + e_input_key_down_filter = e_input_event_filter_add(input_event_source, ECORE_EVENT_KEY_DOWN, _e_mod_ecore_key_down_cb, NULL); context = create_input_method_context(client, input_method); EINA_SAFETY_ON_NULL_GOTO(context, err); @@ -1567,11 +1597,8 @@ _e_text_input_cb_input_panel_data_set(struct wl_client *client EINA_UNUSED, stru const char *szWillHideAck = "WILL_HIDE_ACK"; if (strncmp(data, szWillHideAck, strlen(szWillHideAck)) == 0) { - if (g_timer_will_hide) - { - ecore_timer_del(g_timer_will_hide); - g_timer_will_hide = NULL; - } + _cancel_will_hide_timer(); + INF("WILL_HIDE_ACK_RECVED, %d", g_input_panel_state); if (g_input_panel_state == E_INPUT_PANEL_STATE_WILL_HIDE) { @@ -2210,11 +2237,8 @@ _pol_cb_hook_client_del(void *d EINA_UNUSED, E_Client *ec) LOGE("fail to remove surface\n"); g_input_panel_state = E_INPUT_PANEL_STATE_DID_HIDE; - if (g_timer_will_hide) - { - ecore_timer_del(g_timer_will_hide); - g_timer_will_hide = NULL; - } + _cancel_will_hide_timer(); + client_surface_ec = NULL; LOGI("TRANSIENT_FOR::Reset transient_for_ec to NULL\n"); } @@ -2322,11 +2346,7 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED) E_FREE_LIST(handlers, ecore_event_handler_del); E_FREE_LIST(hooks_ec, e_client_hook_del); - if (g_timer_will_hide) - { - ecore_timer_del(g_timer_will_hide); - g_timer_will_hide = NULL; - } + _cancel_will_hide_timer(); vconf_ignore_key_changed(VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, _keyboard_mode_changed_cb);