e_input_backend: reduce duplicated code to init libinput devices 53/325053/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 2 Jun 2025 02:52:44 +0000 (11:52 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Mon, 2 Jun 2025 06:27:25 +0000 (15:27 +0900)
Change-Id: I7863dba668fde1f2b724479f5242fce7d38ccd89
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/bin/inputmgr/e_input_backend.c

index 6ae361a30995aee5fd40e1144bef59872996b088..dfb254909709d603cffcb9ad0df9a5b3d98c4a77 100644 (file)
@@ -1921,10 +1921,33 @@ err:
 }
 
 static void
-_einput_device_input_thread_path_backend_heavy(void *data, Ecore_Thread *th, void *msg_data)
+_einput_device_init_libinput_device_from_env(struct libinput *libinput, int ndevices)
 {
    char *env = NULL;
    struct libinput_device *device;
+
+   TRACE_INPUT_BEGIN(libinput_path_add_device_loop);
+   for (int i = 0; i < ndevices; i++)
+     {
+        char buf[1024] = "PATH_DEVICE_";
+        eina_convert_itoa(i + 1, buf + 12);
+        env = e_util_env_get(buf);
+        if (env)
+          {
+             device = libinput_path_add_device(libinput, env);
+             if (!device)
+               ERR("Failed to initialized device %s", env);
+             else
+               INF("libinput_path created input device %s", env);
+             E_FREE(env);
+          }
+     }
+   TRACE_INPUT_END();
+}
+
+static void
+_einput_device_input_thread_path_backend_heavy(void *data, Ecore_Thread *th, void *msg_data)
+{
    E_Input_Backend *input = (E_Input_Backend *)data;
 
    EINA_SAFETY_ON_NULL_RETURN(input);
@@ -1953,24 +1976,7 @@ _einput_device_input_thread_path_backend_heavy(void *data, Ecore_Thread *th, voi
         libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
      }
 
-   TRACE_INPUT_BEGIN(libinput_path_add_device_loop);
-   for (int i = 0; i < input->path_ndevices; i++)
-     {
-        char buf[1024] = "PATH_DEVICE_";
-        eina_convert_itoa(i + 1, buf + 12);
-        env = e_util_env_get(buf);
-
-        if (env)
-          {
-             device = libinput_path_add_device(input->libinput, env);
-             if (!device)
-               ERR("Failed to initialized device %s", env);
-             else
-               INF("libinput_path created input device %s", env);
-             E_FREE(env);
-          }
-     }
-   TRACE_INPUT_END();
+   _einput_device_init_libinput_device_from_env(input->libinput, input->path_ndevices);
 
    return;
 }
@@ -2030,7 +2036,6 @@ EINTERN E_Input_Backend *
 e_input_backend_create_libinput_path(int ndevices)
 {
    E_Input_Backend *input;
-   struct libinput_device *device;
    char *env;
 
    /* try to allocate space for new input structure */
@@ -2087,23 +2092,7 @@ e_input_backend_create_libinput_path(int ndevices)
         libinput_log_set_priority(input->libinput, LIBINPUT_LOG_PRIORITY_INFO);
      }
 
-   TRACE_INPUT_BEGIN(libinput_path_add_device_loop);
-   for (int i = 0; i < ndevices; i++)
-     {
-        char buf[1024] = "PATH_DEVICE_";
-        eina_convert_itoa(i + 1, buf + 12);
-        env = e_util_env_get(buf);
-        if (env)
-          {
-             device = libinput_path_add_device(input->libinput, env);
-             if (!device)
-               ERR("Failed to initialized device %s", env);
-             else
-               INF("libinput_path created input device %s", env);
-             E_FREE(env);
-          }
-     }
-   TRACE_INPUT_END();
+   _einput_device_init_libinput_device_from_env(input->libinput, ndevices);
 
    /* enable this input */
    if (!e_input_backend_enable_input(input))