e_input_evdev: generate relative mouse event asynchronously 69/318469/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 27 Sep 2024 05:40:54 +0000 (14:40 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Mon, 30 Sep 2024 07:36:56 +0000 (16:36 +0900)
Change-Id: I4e8664b55f80c55220ad1cb544bd299cc8069f81
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/bin/inputmgr/e_input_evdev.c

index 310dedf5625bed4b2a9fc887fb307454254cca51..3968d09bc3dda2212195ffade6d5f4aca257a80c 100644 (file)
@@ -1036,11 +1036,10 @@ _device_pointer_relative_motion(E_Input_Evdev *evdev, struct libinput_event_poin
 {
    E_Input_Backend *input;
    Ecore_Event_Mouse_Relative_Move *ev;
-   Ecore_Device *ecore_dev = NULL, *data, *detent_data = NULL;
-   Eina_List *l;
    E_Comp_Config *comp_conf;
    const char *device_name = NULL;
    uint32_t timestamp = 0;
+   E_Input_Event_Info *input_event = NULL;
 
    if (!(input = evdev->seat->input)) return;
 
@@ -1048,45 +1047,6 @@ _device_pointer_relative_motion(E_Input_Evdev *evdev, struct libinput_event_poin
    if (event)
      timestamp = libinput_event_pointer_get_time(event);
 
-   ecore_thread_main_loop_begin();
-
-   if (evdev->ecore_dev) ecore_dev = evdev->ecore_dev;
-   else if (evdev->ecore_dev_list && eina_list_count(evdev->ecore_dev_list) > 0)
-     {
-        EINA_LIST_FOREACH(evdev->ecore_dev_list, l, data)
-          {
-             if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_MOUSE)
-               {
-                  ecore_dev = data;
-                  break;
-               }
-             else if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_NONE)
-               {
-                  detent_data = data;
-               }
-          }
-        if (!ecore_dev && e_devicemgr_detent_is_detent(device_name))
-          {
-             ecore_dev = detent_data;
-          }
-     }
-   else
-     {
-        evdev->ecore_dev = e_input_evdev_ecore_device_get(evdev->path, ECORE_DEVICE_CLASS_MOUSE);
-        ecore_dev = evdev->ecore_dev;
-     }
-
-   if (!ecore_dev)
-     {
-        ERR("Failed to get source ecore device from event !\n");
-        goto end;
-     }
-   else if ((detent_data == ecore_dev) || e_devicemgr_detent_is_detent(ecore_device_name_get(ecore_dev)))
-     {
-        /* Do not process detent device's move events. */
-        goto end;
-     }
-
    if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Relative_Move)))) return;
 
    ev->window = (Ecore_Window)input->dev->window;
@@ -1100,16 +1060,19 @@ _device_pointer_relative_motion(E_Input_Evdev *evdev, struct libinput_event_poin
    ev->dx_unaccel = (int)dx[1];
    ev->dy_unaccel = (int)dy[1];
 
-   ev->dev = ecore_device_ref(ecore_dev);
-
    comp_conf = e_comp_config_get();
    if (comp_conf && comp_conf->input_log_enable)
-     ELOGF("Mouse", "Relative Move (time: %d, dx: %.2f, dy: %.2f, unaccel(%.2f, %.2f) device: %s)", NULL, ev->timestamp, dx[0], dy[0], dx[1], dy[1], ecore_device_name_get(ev->dev));
+     ELOGF("Mouse", "Relative Move (time: %d, dx: %.2f, dy: %.2f, unaccel(%.2f, %.2f) device: %s)", NULL, ev->timestamp, dx[0], dy[0], dx[1], dy[1], device_name);
 
-   ecore_event_add(ECORE_EVENT_MOUSE_RELATIVE_MOVE, ev, _e_input_event_mouse_relative_move_cb_free, NULL);
+   input_event = E_NEW(E_Input_Event_Info, 1);
+   input_event->touch_event = EINA_FALSE;
+   input_event->evdev = evdev;
+   input_event->ev = ev;
+   input_event->event_type = ECORE_EVENT_MOUSE_RELATIVE_MOVE;
+   input_event->free_func = _e_input_event_mouse_relative_move_cb_free;
+   input_event->free_func_data = NULL;
 
-end:
-   ecore_thread_main_loop_end();
+   ecore_main_loop_thread_safe_call_async(_pointer_touch_ecore_event_add, input_event);
 }
 
 static unsigned int
@@ -1841,6 +1804,11 @@ _pointer_touch_ecore_event_add(void *data)
         Ecore_Event_Mouse_Move *ev = input_info->ev;
         ev->dev = ecore_device_ref(ecore_dev);
      }
+   else if (input_info->event_type == ECORE_EVENT_MOUSE_RELATIVE_MOVE)
+     {
+        Ecore_Event_Mouse_Relative_Move *ev = input_info->ev;
+        ev->dev = ecore_device_ref(ecore_dev);
+     }
    else if (input_info->event_type == ECORE_EVENT_MOUSE_WHEEL)
      {
         Ecore_Event_Mouse_Wheel *ev = input_info->ev;