From c005aae716fb30c650088fe5c184497c2c165a39 Mon Sep 17 00:00:00 2001 From: Sungmin Kwak Date: Fri, 19 Jan 2018 10:54:23 +0900 Subject: [PATCH] Control key repeat rate Only if ISF_KEY_REPEAT_RATE environment variable is available Change-Id: Id42d6db03b00d07cc900221d5471e191feb1903c --- ism/extras/wayland_immodule/wayland_imcontext.c | 47 +++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/ism/extras/wayland_immodule/wayland_imcontext.c b/ism/extras/wayland_immodule/wayland_imcontext.c index 02c7cc9..bc699fb 100644 --- a/ism/extras/wayland_immodule/wayland_imcontext.c +++ b/ism/extras/wayland_immodule/wayland_imcontext.c @@ -143,6 +143,9 @@ static Eina_Bool _preedit_cursor_changed = EINA_FALSE; static Input_Language input_lang = INPUT_LANG_OTHER; static Evas_Coord g_scr_w = 0, g_scr_h = 0; + +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; // typedef struct __LanguageInfo { @@ -1376,6 +1379,33 @@ set_focus(Ecore_IMF_Context *ctx) wl_text_input_activate(imcontext->text_input, seat, ecore_wl2_window_surface_get(imcontext->window)); + if (g_key_rate_checked == EINA_FALSE && g_desired_key_rate == 0.0) { + char *key_rate = getenv ("ISF_KEY_REPEAT_RATE"); + if (key_rate) { + g_desired_key_rate = atof (key_rate); + if (g_desired_key_rate > 0.0) { + if (!ecore_wl2_input_keyboard_repeat_get (input, &g_original_key_rate, &g_original_key_delay)) { + LOGE ("ecore_wl2_input_keyboard_repeat_get failed"); + } + else { + LOGD ("ecore_wl2_input_keyboard_repeat_get original rate=%f, delay=%f. Desired rate=%f", + g_original_key_rate, g_original_key_delay, g_desired_key_rate); + } + } + } + g_key_rate_checked = EINA_TRUE; + } + + if (g_desired_key_rate > 0.0 && g_original_key_delay > 0.0 && !g_focused) { + g_focused = EINA_TRUE; + if (!ecore_wl2_input_keyboard_repeat_set (input, g_desired_key_rate, g_original_key_delay)) { + LOGE ("ecore_wl2_input_keyboard_repeat_set failed"); + } + else { + LOGD ("ecore_wl2_input_keyboard_repeat_set(%f, %f)", g_desired_key_rate, g_original_key_delay); + } + } + return EINA_TRUE; } @@ -1405,6 +1435,23 @@ set_focus_out(Ecore_IMF_Context *ctx) imcontext->input = NULL; _preedit_cursor_changed = EINA_FALSE; + + if (g_desired_key_rate > 0.0 && g_focused) { + g_focused = EINA_FALSE; + + Ecore_Wl2_Input *input = ecore_wl2_window_input_get(imcontext->window); + if (input) { + if (!ecore_wl2_input_keyboard_repeat_set (input, g_original_key_rate, g_original_key_delay)) { + LOGE ("ecore_wl2_input_keyboard_repeat_set failed."); + } + else { + LOGD ("ecore_wl2_input_keyboard_repeat_set(%f, %f)", g_original_key_rate, g_original_key_delay); + } + } + else { + LOGW("ctx : %p, Can't get Wl_Input", ctx); + } + } } // TIZEN_ONLY(20160217): ignore the duplicate show request -- 2.7.4