e_input: modified to add/remove device within an ecore main thread 81/299981/1
authorInhong Han <inhong1.han@samsung.com>
Fri, 13 Oct 2023 05:40:35 +0000 (14:40 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Fri, 13 Oct 2023 06:30:03 +0000 (15:30 +0900)
Change-Id: I1736dddb1b760cd79ce4a1bcb4a60041d3a0de59

src/bin/e_input_inputs.c

index b29d49adcb032f27eacf199fb8dbf2b22fed122d..c9df039b413fe09aa8a3185914a3590edab2176b 100644 (file)
@@ -209,8 +209,6 @@ _e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
 
    if (!edev || !edev->path) return EINA_FALSE;
 
-   ecore_thread_main_loop_begin();
-
    dev_list = ecore_device_list();
    if (dev_list)
      {
@@ -222,7 +220,6 @@ _e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
              if ((ecore_device_class_get(dev) == clas) && (!strcmp(identifier, edev->path)))
                {
                   ERR("Found same device in device list");
-                  ecore_thread_main_loop_end();
                   return EINA_FALSE;
                }
           }
@@ -234,7 +231,6 @@ _e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
      {
         ERR("Failed to create ecore device");
         edev->ecore_dev = NULL;
-        ecore_thread_main_loop_end();
         return EINA_FALSE;
      }
 
@@ -289,7 +285,6 @@ _e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
           {
              ERR("Failed to add e device");
              edev->e_dev = NULL;
-             ecore_thread_main_loop_end();
              return EINA_FALSE;
           }
      }
@@ -323,7 +318,6 @@ _e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
 
    _e_input_ecore_device_event(dev, edev->seat ? edev->seat->name : NULL, EINA_TRUE);
 
-   ecore_thread_main_loop_end();
    return EINA_TRUE;
 }
 
@@ -340,7 +334,6 @@ _e_input_remove_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
    dev_list = ecore_device_list();
    if (!dev_list) return EINA_FALSE;
 
-   ecore_thread_main_loop_begin();
    EINA_LIST_FOREACH(dev_list, l, dev)
       {
          if (!dev) continue;
@@ -366,11 +359,10 @@ _e_input_remove_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
                 }
               _e_input_ecore_device_event(dev, edev->seat ? edev->seat->name : NULL, EINA_FALSE);
               ecore_device_del(dev);
-              ecore_thread_main_loop_end();
               return EINA_TRUE;
            }
       }
-   ecore_thread_main_loop_end();
+
    return EINA_FALSE;
 }
 
@@ -427,7 +419,6 @@ _e_input_device_remove(E_Input_Evdev *edev)
      {
         if (eina_list_count(edev->ecore_dev_list) > 0)
           {
-             ecore_thread_main_loop_begin();
              EINA_LIST_FREE(edev->ecore_dev_list, data)
                {
                   WRN("Invalid device is left. name: %s, identifier: %s, clas: %s\n",
@@ -437,7 +428,6 @@ _e_input_device_remove(E_Input_Evdev *edev)
                   ecore_device_unref(data);
                   ecore_device_del(data);
                }
-             ecore_thread_main_loop_end();
           }
         edev->ecore_dev_list = NULL;
      }
@@ -451,6 +441,7 @@ _device_added(E_Input_Backend *input, struct libinput_device *device)
    E_Input_Seat *seat;
    E_Input_Evdev *edev;
 
+   ecore_thread_main_loop_begin();
    libinput_seat = libinput_device_get_seat(device);
    seat_name = libinput_seat_get_logical_name(libinput_seat);
 
@@ -458,6 +449,7 @@ _device_added(E_Input_Backend *input, struct libinput_device *device)
    if (!(seat = _seat_get(input, seat_name)))
      {
         ERR("Could not get matching seat: %s", seat_name);
+        ecore_thread_main_loop_end();
         return;
      }
 
@@ -465,6 +457,7 @@ _device_added(E_Input_Backend *input, struct libinput_device *device)
    if (!(edev = _e_input_evdev_device_create(seat, device)))
      {
         ERR("Failed to create new evdev device");
+        ecore_thread_main_loop_end();
         return;
      }
 
@@ -474,8 +467,11 @@ _device_added(E_Input_Backend *input, struct libinput_device *device)
    if (EINA_FALSE == _e_input_device_add(edev))
      {
         ERR("Failed to create evas device !\n");
+        ecore_thread_main_loop_end();
         return;
      }
+
+   ecore_thread_main_loop_end();
 }
 
 static void
@@ -483,9 +479,12 @@ _device_removed(E_Input_Backend *input, struct libinput_device *device)
 {
    E_Input_Evdev *edev;
 
+   ecore_thread_main_loop_begin();
+
    /* try to get the evdev structure */
    if (!(edev = libinput_device_get_user_data(device)))
      {
+        ecore_thread_main_loop_end();
         return;
      }
 
@@ -496,6 +495,8 @@ _device_removed(E_Input_Backend *input, struct libinput_device *device)
 
    /* destroy this evdev */
    _e_input_evdev_device_destroy(edev);
+
+   ecore_thread_main_loop_end();
 }
 
 static int