From 677c6a489e53d29c265a999fe5f409e1edfc3c5e Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 22 Feb 2021 10:41:44 +0900 Subject: [PATCH] Fix bug that the key is not entered after the timeout occurred There is no code to initialize the variable that is check the timeout. So I modified the code to initialize this variable when focus_out() is called or when IME processed the last key event and modified to allow the app to handle modifier keys even if timeout occurs. Change-Id: I89707f6b00d7b26a54ef0066c110c1a126e27cb8 --- ism/extras/wayland_immodule/wayland_imcontext.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/ism/extras/wayland_immodule/wayland_imcontext.c b/ism/extras/wayland_immodule/wayland_imcontext.c index 4a62e10..48eac33 100644 --- a/ism/extras/wayland_immodule/wayland_imcontext.c +++ b/ism/extras/wayland_immodule/wayland_imcontext.c @@ -147,6 +147,7 @@ static void set_autocapital (Ecore_IMF_Context *ctx); static Eina_Bool g_key_rate_checked = EINA_FALSE, g_focused = EINA_FALSE; static double g_original_key_rate = 0.0, g_original_key_delay = 0.0, g_desired_key_rate = 0.0; static double g_filter_event_elapsed_time = 0.0; +static int g_last_key_event_serial = 0; // typedef struct __LanguageInfo { @@ -1485,6 +1486,8 @@ set_focus_out(Ecore_IMF_Context *ctx) imcontext->input = NULL; _preedit_cursor_changed = EINA_FALSE; + g_filter_event_elapsed_time = 0.0; + g_last_key_event_serial = 0; if (g_desired_key_rate > 0.0 && g_focused) { g_focused = EINA_FALSE; @@ -3459,15 +3462,6 @@ wayland_im_context_filter_event(Ecore_IMF_Context *ctx, break; } - if (!_check_filter_event(imcontext)) { - LOGE("elapsed time : %.3f ms, serial (last, require) : (%d, %d)", g_filter_event_elapsed_time * 1000, imcontext->last_key_event_filter.serial, imcontext->serial + 1); - ret = EINA_TRUE; - break; - } - - int serial = imcontext->serial++; - double start_time = ecore_time_get(); - /* xkb_mod_mask */ uint32_t modifiers = 0; if (ecore_key_ev.modifiers & ECORE_EVENT_MODIFIER_SHIFT) @@ -3481,6 +3475,19 @@ wayland_im_context_filter_event(Ecore_IMF_Context *ctx, if (ecore_key_ev.modifiers & ECORE_EVENT_LOCK_NUM) modifiers |= imcontext->num_mask; + if (g_last_key_event_serial <= imcontext->last_key_event_filter.serial) + g_filter_event_elapsed_time = 0.0; + + if (!_check_filter_event(imcontext)) { + LOGE("elapsed time : %.3f ms, serial (last, require) : (%d, %d)", g_filter_event_elapsed_time * 1000, imcontext->last_key_event_filter.serial, imcontext->serial + 1); + ret = modifiers ? EINA_FALSE : EINA_TRUE; + break; + } + + int serial = imcontext->serial++; + g_last_key_event_serial = serial; + double start_time = ecore_time_get(); + SECURE_LOGD ("ev:modifiers=0x%x, modifiers=0x%x, shift_mask=0x%x, control_mask=0x%0x, alt_mask=0x%x, caps_mask=0x%x, num_mask=0x%x, keycode=%u", ecore_key_ev.modifiers, modifiers, imcontext->shift_mask, imcontext->control_mask, imcontext->alt_mask, imcontext->caps_mask, imcontext->num_mask, ecore_key_ev.keycode); //Send key event to IME. wl_text_input_filter_key_event(imcontext->text_input, serial, ecore_key_ev.timestamp, ecore_key_ev.key, -- 2.7.4