From 07a7cb8e313bc6718c31433bca1ee9be9988cd05 Mon Sep 17 00:00:00 2001 From: Li Zhang Date: Thu, 8 Sep 2016 16:08:47 +0800 Subject: [PATCH] Next key event should be processed next to current key event Change-Id: I069d673ac67ca919e600967d1d043cc6a7edd63d Signed-off-by: Jihoon Kim --- ism/extras/wayland_immodule/wayland_imcontext.c | 79 ++++++++++++------------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/ism/extras/wayland_immodule/wayland_imcontext.c b/ism/extras/wayland_immodule/wayland_imcontext.c index b82bfc7..e0ac9cc 100644 --- a/ism/extras/wayland_immodule/wayland_imcontext.c +++ b/ism/extras/wayland_immodule/wayland_imcontext.c @@ -1981,55 +1981,54 @@ wayland_im_context_filter_event(Ecore_IMF_Context *ctx, if (type == ECORE_IMF_EVENT_KEY_UP || type == ECORE_IMF_EVENT_KEY_DOWN) { WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get(ctx); + if (!imcontext) + return EINA_FALSE; if (!_focused_ctx) { LOGD ("no focus\n"); return EINA_FALSE; } - if (!imcontext) - return EINA_FALSE; - - if (!ecore_key_ev.timestamp && (ecore_key_ev.modifiers & MOD_Mod5_MASK)) { - LOGD("Return! This is SW keyboard fake event!"); - return EINA_FALSE; - } + do { + if (!ecore_key_ev.timestamp && (ecore_key_ev.modifiers & MOD_Mod5_MASK)) { + LOGD("Return! This is SW keyboard fake event!"); + 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) - modifiers |= imcontext->shift_mask; - if (ecore_key_ev.modifiers & ECORE_EVENT_MODIFIER_CTRL) - modifiers |= imcontext->control_mask; - if (ecore_key_ev.modifiers & ECORE_EVENT_MODIFIER_ALT) - modifiers |= imcontext->alt_mask; - - LOGD ("ev:modifiers=%d, modifiers=%d, shift_mask=%d, control_mask=%d, alt_mask=%d", ecore_key_ev.modifiers, modifiers, imcontext->shift_mask, imcontext->control_mask, imcontext->alt_mask); - //Send key event to IME. - wl_text_input_filter_key_event(imcontext->text_input, serial, ecore_key_ev.timestamp, ecore_key_ev.key, - type == ECORE_IMF_EVENT_KEY_UP? WL_KEYBOARD_KEY_STATE_RELEASED : WL_KEYBOARD_KEY_STATE_PRESSED, - modifiers); - //Waiting for filter_key_event_done from IME. - //This function should return IME filtering result with boolean type. - struct wl_display *display = ecore_wl_display_get(); - if (display) { - while (ecore_time_get() - start_time < WAIT_FOR_FILTER_DONE_SECOND) { - wl_display_dispatch(display); - - if (imcontext->last_key_event_filter.serial == serial) { - ret = imcontext->last_key_event_filter.state; - break; - } else if (imcontext->last_key_event_filter.serial > serial) - return EINA_FALSE; + 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) + modifiers |= imcontext->shift_mask; + if (ecore_key_ev.modifiers & ECORE_EVENT_MODIFIER_CTRL) + modifiers |= imcontext->control_mask; + if (ecore_key_ev.modifiers & ECORE_EVENT_MODIFIER_ALT) + modifiers |= imcontext->alt_mask; + + LOGD ("ev:modifiers=%d, modifiers=%d, shift_mask=%d, control_mask=%d, alt_mask=%d", ecore_key_ev.modifiers, modifiers, imcontext->shift_mask, imcontext->control_mask, imcontext->alt_mask); + //Send key event to IME. + wl_text_input_filter_key_event(imcontext->text_input, serial, ecore_key_ev.timestamp, ecore_key_ev.key, + type == ECORE_IMF_EVENT_KEY_UP? WL_KEYBOARD_KEY_STATE_RELEASED : WL_KEYBOARD_KEY_STATE_PRESSED, + modifiers); + //Waiting for filter_key_event_done from IME. + //This function should return IME filtering result with boolean type. + struct wl_display *display = ecore_wl_display_get(); + if (display) { + while (ecore_time_get() - start_time < WAIT_FOR_FILTER_DONE_SECOND) { + wl_display_dispatch(display); + + if (imcontext->last_key_event_filter.serial == serial) { + ret = imcontext->last_key_event_filter.state; + break; + } else if (imcontext->last_key_event_filter.serial > serial) + break; + } } - } - else - return EINA_FALSE; + LOGD ("elapsed : %.3f ms, serial (last, require) : (%d, %d)", (ecore_time_get() - start_time)*1000, imcontext->last_key_event_filter.serial, serial); + } while (0); - LOGD ("elapsed : %.3f ms, serial (last, require) : (%d, %d)", (ecore_time_get() - start_time)*1000, imcontext->last_key_event_filter.serial, serial); //Deal with the next key event in list. Ecore_Event_Key *ev = NULL; if (eina_list_count (imcontext->keysym_list)) { -- 2.7.4