From 0089cc5c91fbecf7ecdb2466a2d0c621cf6f1afd Mon Sep 17 00:00:00 2001 From: Inhong Han Date: Fri, 17 Nov 2023 13:29:07 +0900 Subject: [PATCH] Print log when processing of key event is delayed Change-Id: Id6387732b085aa93478984caa9b474d32b19bb85 --- src/bin/e_config.c | 2 ++ src/bin/e_config.h | 1 + src/bin/e_input_evdev.c | 2 ++ src/bin/e_input_inputs.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/bin/e_input_private.h | 2 ++ 5 files changed, 52 insertions(+) diff --git a/src/bin/e_config.c b/src/bin/e_config.c index cbd932a..fa48ca3 100644 --- a/src/bin/e_config.c +++ b/src/bin/e_config.c @@ -309,6 +309,7 @@ _e_config_edd_init(Eina_Bool old) E_CONFIG_VAL(D, T, resize_object.image_path, STR); E_CONFIG_VAL(D, T, calc_vis_ignore_geometry, UINT); E_CONFIG_VAL(D, T, input_thread_mode, UCHAR); + E_CONFIG_VAL(D, T, key_input_time_limit, UINT); } static Eina_Bool @@ -569,6 +570,7 @@ e_config_load(void) E_CONFIG_LIMIT(e_config->resize_object.border_width.b, 0, 128); E_CONFIG_LIMIT(e_config->calc_vis_ignore_geometry, 0, 1); E_CONFIG_LIMIT(e_config->input_thread_mode, 0, 1); + E_CONFIG_LIMIT(e_config->key_input_time_limit, 0, 500); } EINTERN int diff --git a/src/bin/e_config.h b/src/bin/e_config.h index ad2e812..68eb052 100644 --- a/src/bin/e_config.h +++ b/src/bin/e_config.h @@ -310,6 +310,7 @@ struct _E_Config Eina_Bool calc_vis_ignore_geometry; // 0: unset ignore geometry, 1: ignore geometry calculate when the calculation of visibility. Eina_Bool input_thread_mode; // 0: process key input event in main thread, 1: process key input event in input thread + unsigned int key_input_time_limit; }; struct _E_Config_Desklock_Background diff --git a/src/bin/e_input_evdev.c b/src/bin/e_input_evdev.c index bc14bdc..3f5f079 100644 --- a/src/bin/e_input_evdev.c +++ b/src/bin/e_input_evdev.c @@ -799,6 +799,8 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar if (comp_conf && comp_conf->input_log_enable) ELOGF("Key", "%s (keyname: %s, keycode: %d, timestamp: %u, device: %s)", NULL, state?"Press":"Release", e->keyname, e->keycode, e->timestamp, device_name); + _e_input_key_event_list_add(e); + if (e_input_thread_mode_get()) { e->dev = (Eo *)g_object_ref(e_dev); diff --git a/src/bin/e_input_inputs.c b/src/bin/e_input_inputs.c index 1c1e561..be014f0 100644 --- a/src/bin/e_input_inputs.c +++ b/src/bin/e_input_inputs.c @@ -9,6 +9,7 @@ static gboolean input_dispatch(GSource *source, GSourceFunc callback, gpointer u static gboolean input_thread_prepare(GSource *source, gint *time); static E_Input_Event_Source *g_input_event_source = NULL; +static GList *_key_event_list = NULL; GSourceFuncs input_event_funcs = { .prepare = input_thread_prepare, @@ -604,12 +605,41 @@ _cb_input_dispatch(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED) return EINA_TRUE; } +static void +_e_input_delayed_key_events_print() +{ + struct timespec tp; + unsigned int time; + + clock_gettime(CLOCK_MONOTONIC, &tp); + time = (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L); + + for (GList *list = g_list_first(_key_event_list); list; list = list->next) + { + Ecore_Event_Key *key = (Ecore_Event_Key *)list->data; + if (!key) continue; + + if (e_config->key_input_time_limit <= (time - key->timestamp)) + ERR("Delayed key event : keyname(%s), keycode(%u), timestamp(%u), elapsed_time(%u ms)", key->keyname, key->keycode, key->timestamp, time - key->timestamp); + + if (key->keyname) + eina_stringshare_del(key->keyname); + E_FREE(key); + + _key_event_list = g_list_delete_link(_key_event_list, list); + } + _key_event_list = NULL; +} + static gboolean input_thread_prepare(GSource *source, gint *time) { /* flush only focused client events */ e_comp_wl_focused_client_flush(); + if (_key_event_list) + _e_input_delayed_key_events_print(); + if (time) *time = -1; @@ -741,6 +771,21 @@ input_thread_cancel(void *data, Ecore_Thread *th) input->input_thread = NULL; } +void +_e_input_key_event_list_add(Ecore_Event_Key *key) +{ + Ecore_Event_Key *clone = E_NEW(Ecore_Event_Key, 1); + if (!clone || !key) return; + + if (key->keyname) + clone->keyname = (char *)eina_stringshare_add(key->keyname); + + clone->keycode = key->keycode; + clone->timestamp = key->timestamp; + + _key_event_list = g_list_append(_key_event_list, clone); +} + EINTERN Eina_Bool e_input_enable_input(E_Input_Backend *input) { diff --git a/src/bin/e_input_private.h b/src/bin/e_input_private.h index 79100df..8d0a526 100644 --- a/src/bin/e_input_private.h +++ b/src/bin/e_input_private.h @@ -190,5 +190,7 @@ Eina_Bool e_input_evdev_seatname_set(E_Input_Evdev *evdev, const char *seatname) void _e_input_hook_call(E_Input_Hook_Point hookpoint, const char *device_name); +void _e_input_key_event_list_add(Ecore_Event_Key *key); + #endif #endif -- 2.7.4