e_input_backend: add ecore device for seat asynchronously 55/315655/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Tue, 3 Dec 2024 07:50:41 +0000 (16:50 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 4 Dec 2024 04:58:02 +0000 (04:58 +0000)
Change-Id: Ie157549f170c85c30a01c970219dc13ee070ac3a
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/bin/inputmgr/e_input_backend.c

index c424fd9189e0537af04a7d8dbc215dcb4e0c0e98..094a495f7f794509b241aeeef79c8a3d88000978 100644 (file)
@@ -165,35 +165,43 @@ _e_input_ecore_device_event(Ecore_Device *dev, const char* seat_name, Eina_Bool
      ecore_event_add(ECORE_EVENT_DEVICE_DEL, e, _e_input_ecore_device_info_free, NULL);
 }
 
-static E_Input_Seat *
-_seat_create(E_Input_Backend *input, const char *seat)
+static void
+_e_input_seat_ecore_device_create_async_cb(void *data)
 {
-   E_Input_Seat *s;
+   E_Input_Seat *s = data;
    Ecore_Device *ecore_dev = NULL;
-   E_Device *e_dev = NULL;
-
-   ecore_thread_main_loop_begin();
 
    /* create an evas device of a seat */
    ecore_dev = ecore_device_add();
    if (!ecore_dev)
      {
         ERR("Failed to create an ecore device for a seat !\n");
-        ecore_thread_main_loop_end();
-        return NULL;
+        return;
      }
 
-   ecore_device_name_set(ecore_dev, seat);
+   ecore_device_name_set(ecore_dev, s->name);
    ecore_device_identifier_set(ecore_dev, "Enlightenment seat");
    ecore_device_class_set(ecore_dev, ECORE_DEVICE_CLASS_SEAT);
    ecore_device_subclass_set(ecore_dev, ECORE_DEVICE_SUBCLASS_NONE);
 
+   s->ecore_dev = ecore_dev;
+
+   ecore_event_add(E_INPUT_EVENT_SEAT_ADD, NULL, NULL, NULL);
+
+   _e_input_ecore_device_event(ecore_dev, s->name, EINA_TRUE);
+}
+
+static E_Input_Seat *
+_seat_create(E_Input_Backend *input, const char *seat)
+{
+   E_Input_Seat *s = NULL;
+   E_Device *e_dev = NULL;
+
    /* create an e device of a seat */
    e_dev = e_device_new();
    if (!e_dev)
      {
         ERR("Failed to create an ecore device for a seat !\n");
-        ecore_thread_main_loop_end();
         return NULL;
      }
 
@@ -205,24 +213,19 @@ _seat_create(E_Input_Backend *input, const char *seat)
    /* try to allocate space for new seat */
    if (!(s = calloc(1, sizeof(E_Input_Seat))))
      {
-        ecore_device_del(ecore_dev);
-        ecore_thread_main_loop_end();
         return NULL;
      }
 
    s->input = input;
    s->name = eina_stringshare_add(seat);
-   s->ecore_dev = ecore_dev;
+   s->ecore_dev = NULL;
    s->e_dev = e_dev;
 
    /* add this new seat to list */
    input->dev->seats = eina_list_append(input->dev->seats, s);
    s->dev = input->dev;
 
-   ecore_event_add(E_INPUT_EVENT_SEAT_ADD, NULL, NULL, NULL);
-
-   _e_input_ecore_device_event(ecore_dev, seat, EINA_TRUE);
-   ecore_thread_main_loop_end();
+   ecore_main_loop_thread_safe_call_async(_e_input_seat_ecore_device_create_async_cb, s);
 
    return s;
 }