From 33cd2e39301081e24111310bea478f189b1c5409 Mon Sep 17 00:00:00 2001 From: zhengxinjian Date: Mon, 10 Apr 2023 10:40:51 +0800 Subject: Update the control logic for key repeat rate Change-Id: I7f457692b317a75bc5da8bf83f4cc45b0139d823 --- ism/extras/wayland_immodule/wayland_imcontext.c | 26 ++++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/ism/extras/wayland_immodule/wayland_imcontext.c b/ism/extras/wayland_immodule/wayland_imcontext.c index 3dff2f32..ad034b81 100644 --- a/ism/extras/wayland_immodule/wayland_imcontext.c +++ b/ism/extras/wayland_immodule/wayland_imcontext.c @@ -157,7 +157,7 @@ static Input_Language input_lang = INPUT_LANG_OTHER; static void set_autocapital (Ecore_IMF_Context *ctx); -static Eina_Bool g_key_rate_checked = EINA_FALSE, g_focused = EINA_FALSE; +static Eina_Bool 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; @@ -1525,21 +1525,18 @@ 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); - } + 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) { @@ -1587,6 +1584,7 @@ set_focus_out(Ecore_IMF_Context *ctx) if (g_desired_key_rate > 0.0 && g_focused) { g_focused = EINA_FALSE; + g_desired_key_rate = 0.0; Ecore_Wl2_Input *input = ecore_wl2_window_keyboard_get(imcontext->window); if (input) { -- cgit v1.2.3