e_keyrouter_event: reduce duplicated code for handling key event 24/324324/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Thu, 15 May 2025 09:51:36 +0000 (18:51 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 15 May 2025 10:47:47 +0000 (19:47 +0900)
Change-Id: I5b4d7cf0ab405d3f2993b1a41ef6a187af38c470
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/bin/inputmgr/e_keyrouter_event.c

index a192ebb93c6e81cd058a7ec51f8b64e2191357ac..025cc45130b406286ea43790b0d2fedd38d91a2c 100644 (file)
@@ -672,7 +672,7 @@ _e_keyrouter_send_key_event(int type, struct wl_resource *surface, struct wl_cli
 }
 
 static Eina_Bool
-_e_keyrouter_cb_key_down(void *data, int type, void *event)
+_e_keyrouter_cb_key_event(void *data, int type, void *event)
 {
    Ecore_Event_Key *ev;
 
@@ -680,22 +680,11 @@ _e_keyrouter_cb_key_down(void *data, int type, void *event)
 
    ev = (Ecore_Event_Key *)event;
 
-   TRACE_INPUT_BEGIN(_e_keyrouter_cb_key_down:KEY_PRESS(%d), ev->keycode);
-   TRACE_INPUT_END();
-
-   return _e_keyrouter_event_process(event, (E_Device *)ev->dev, type);
-}
-
-static Eina_Bool
-_e_keyrouter_cb_key_up(void *data, int type, void *event)
-{
-   Ecore_Event_Key *ev;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(event, FALSE);
-
-   ev = (Ecore_Event_Key *)event;
+   if (type == ECORE_EVENT_KEY_DOWN)
+     TRACE_INPUT_BEGIN(_e_keyrouter_cb_key_down:KEY_PRESS(%d), ev->keycode);
+   else
+     TRACE_INPUT_BEGIN(_e_keyrouter_cb_key_up:KEY_RELEASE(%d), ev->keycode);
 
-   TRACE_INPUT_BEGIN(_e_keyrouter_cb_key_up:KEY_RELEASE(%d), ev->keycode);
    TRACE_INPUT_END();
 
    return _e_keyrouter_event_process(event, (E_Device *)ev->dev, type);
@@ -747,8 +736,8 @@ e_keyrouter_event_init(void)
 
    if (!e_input_thread_mode_get())
      {
-        E_LIST_HANDLER_APPEND(krt->handlers, ECORE_EVENT_KEY_DOWN, _e_keyrouter_cb_key_down, NULL);
-        E_LIST_HANDLER_APPEND(krt->handlers, ECORE_EVENT_KEY_UP, _e_keyrouter_cb_key_up, NULL);
+        E_LIST_HANDLER_APPEND(krt->handlers, ECORE_EVENT_KEY_DOWN, _e_keyrouter_cb_key_event, NULL);
+        E_LIST_HANDLER_APPEND(krt->handlers, ECORE_EVENT_KEY_UP, _e_keyrouter_cb_key_event, NULL);
      }
    else
      {
@@ -797,10 +786,10 @@ e_keyrouter_event_handler_add(void)
       }
 
    if (!krt->_key_down_handler)
-     krt->_key_down_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_DOWN, _e_keyrouter_cb_key_down, NULL);
+     krt->_key_down_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_DOWN, _e_keyrouter_cb_key_event, NULL);
 
    if (!krt->_key_up_handler)
-     krt->_key_up_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_UP, _e_keyrouter_cb_key_up, NULL);
+     krt->_key_up_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_UP, _e_keyrouter_cb_key_event, NULL);
 }
 
 ///////////////////////////////////////////////////////////////////////