e_input_backend: process the libinput event at e_input_backend 21/314321/1
authorSooChan Lim <sc1.lim@samsung.com>
Tue, 9 Jul 2024 23:50:23 +0000 (08:50 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 10 Jul 2024 06:13:22 +0000 (15:13 +0900)
The e_input_evdev provides the functions to hadle the libinput event
and e_input_backend has the logic to process the libinput event.

Change-Id: I47e6249777f9b461858faa4587a59019bfeb99ca

src/bin/inputmgr/e_input_backend.c
src/bin/inputmgr/e_input_evdev.c
src/bin/inputmgr/e_input_evdev_intern.h

index 8e58fa8..a3c976f 100644 (file)
@@ -678,11 +678,83 @@ _udev_event_process(struct libinput_event *event)
    return ret;
 }
 
+static Eina_Bool
+_e_input_backend_libinput_event_evdev_process(struct libinput_event *event)
+{
+   E_Input_Evdev *evdev;
+   struct libinput_device *device;
+   Eina_Bool ret = EINA_TRUE;
+
+   device = libinput_event_get_device(event);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, EINA_FALSE);
+
+   evdev = libinput_device_get_user_data(device);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, EINA_FALSE);
+
+   switch (libinput_event_get_type(event))
+     {
+      case LIBINPUT_EVENT_KEYBOARD_KEY:
+        e_input_evdev_handle_key(evdev, libinput_event_get_keyboard_event(event));
+        break;
+      case LIBINPUT_EVENT_POINTER_MOTION:
+        e_input_evdev_handle_pointer_motion(evdev,
+                                      libinput_event_get_pointer_event(event));
+        break;
+      case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
+        e_input_evdev_handle_pointer_motion_absolute(evdev,
+                                               libinput_event_get_pointer_event(event));
+        break;
+      case LIBINPUT_EVENT_POINTER_BUTTON:
+        e_input_evdev_handle_button(evdev, libinput_event_get_pointer_event(event));
+        break;
+      case LIBINPUT_EVENT_POINTER_AXIS:
+#if !LIBINPUT_HAVE_SCROLL_VALUE_V120
+        e_input_evdev_handle_axis(evdev, libinput_event_get_pointer_event(event));
+#endif
+        break;
+#if LIBINPUT_HAVE_SCROLL_VALUE_V120
+      case LIBINPUT_EVENT_POINTER_SCROLL_WHEEL:
+        e_input_evdev_handle_axis_v120(evdev, libinput_event_get_pointer_event(event), E_INPUT_EVDEV_AXIS_SOURCE_WHEEL);
+        break;
+      case LIBINPUT_EVENT_POINTER_SCROLL_FINGER:
+        e_input_evdev_handle_axis_v120(evdev, libinput_event_get_pointer_event(event), E_INPUT_EVDEV_AXIS_SOURCE_FINGER);
+        break;
+      case LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS:
+        e_input_evdev_handle_axis_v120(evdev, libinput_event_get_pointer_event(event), E_INPUT_EVDEV_AXIS_SOURCE_CONTINUOUS);
+        break;
+#endif
+      case LIBINPUT_EVENT_TOUCH_DOWN:
+        e_input_evdev_handle_touch_down(evdev, libinput_event_get_touch_event(event));
+        break;
+      case LIBINPUT_EVENT_TOUCH_MOTION:
+        e_input_evdev_handle_touch_motion(evdev,
+                                    libinput_event_get_touch_event(event));
+        break;
+      case LIBINPUT_EVENT_TOUCH_UP:
+        e_input_evdev_handle_touch_up(evdev, libinput_event_get_touch_event(event));
+        break;
+      case LIBINPUT_EVENT_TOUCH_CANCEL:
+        e_input_evdev_handle_touch_cancel(evdev, libinput_event_get_touch_event(event));
+        break;
+      case LIBINPUT_EVENT_TOUCH_FRAME:
+        e_input_evdev_handle_touch_frame(evdev, libinput_event_get_touch_event(event));
+        break;
+      case LIBINPUT_EVENT_TOUCH_AUX_DATA:
+        e_input_edev_handle_touch_aux_data(evdev, libinput_event_get_touch_aux_data(event));
+        break;
+      default:
+        ret = EINA_FALSE;
+        break;
+     }
+
+   return ret;
+}
+
 static void
 _input_event_process(struct libinput_event *event)
 {
    if (_udev_event_process(event)) return;
-   if (e_input_evdev_event_process(event)) return;
+   if (_e_input_backend_libinput_event_evdev_process(event)) return;
 }
 
 void
index e0e6715..4e97216 100644 (file)
@@ -514,10 +514,9 @@ _e_input_event_key_cb_free(void *data EINA_UNUSED, void *event)
    free(ev);
 }
 
-static void
-_device_handle_key(struct libinput_device *device, struct libinput_event_keyboard *event)
+EINTERN void
+e_input_evdev_handle_key(E_Input_Evdev *evdev, struct libinput_event_keyboard *event)
 {
-   E_Input_Evdev *evdev;
    E_Input_Backend *input;
    uint32_t timestamp;
    uint32_t code, nsyms;
@@ -539,10 +538,7 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
    const char *device_name = NULL;
    Ecore_Device_Subclass device_subclas = ECORE_DEVICE_SUBCLASS_NONE;
 
-   if (!(evdev = libinput_device_get_user_data(device)))
-     {
-        return;
-     }
+   EINA_SAFETY_ON_NULL_RETURN(evdev);
 
    if (!(input = evdev->seat->input))
      {
@@ -1077,18 +1073,14 @@ _device_pointer_motion_send(E_Input_Evdev *evdev, struct libinput_event_pointer
      }
 }
 
-static void
-_device_handle_pointer_motion(struct libinput_device *device, struct libinput_event_pointer *event)
+EINTERN void
+e_input_evdev_handle_pointer_motion(E_Input_Evdev *evdev, struct libinput_event_pointer *event)
 {
-   E_Input_Evdev *evdev;
+   EINA_SAFETY_ON_NULL_RETURN(evdev);
+
    double delta_x[2]; /* delta_x[0] for accelerated, delta_x[1] for unaccelerated */
    double delta_y[2]; /* delta_y[0] for accelerated, delta_y[1] for unaccelerated */
 
-   if (!(evdev = libinput_device_get_user_data(device)))
-     {
-        return;
-     }
-
    delta_x[0] = libinput_event_pointer_get_dx(event);
    delta_x[1] = libinput_event_pointer_get_dx_unaccelerated(event);
    delta_y[0] = libinput_event_pointer_get_dy(event);
@@ -1097,23 +1089,19 @@ _device_handle_pointer_motion(struct libinput_device *device, struct libinput_ev
    _device_pointer_motion_send(evdev, event, &delta_x[0], &delta_y[0]);
 }
 
-static void
-_device_handle_pointer_motion_absolute(struct libinput_device *device, struct libinput_event_pointer *event)
+EINTERN void
+e_input_evdev_handle_pointer_motion_absolute(E_Input_Evdev *evdev, struct libinput_event_pointer *event)
 {
-   E_Input_Evdev *evdev;
-   int w = 0, h = 0;
    E_Output *primary_output;
+   int w = 0, h = 0;
 
-   if (!(evdev = libinput_device_get_user_data(device)))
-     {
-        return;
-     }
+   EINA_SAFETY_ON_NULL_RETURN(evdev);
 
 #ifdef E_DISPLAY
    primary_output = e_display_primary_output_get();
 #else
    primary_output = e_comp_screen_primary_output_get(e_comp->e_comp_screen);
-#endif 
+#endif
 
    e_output_size_get(primary_output, &w, &h);
 
@@ -1140,10 +1128,9 @@ _device_handle_pointer_motion_absolute(struct libinput_device *device, struct li
    _device_pointer_motion(evdev, event);
 }
 
-static void
-_device_handle_button(struct libinput_device *device, struct libinput_event_pointer *event)
+EINTERN void
+e_input_evdev_handle_button(E_Input_Evdev *evdev, struct libinput_event_pointer *event)
 {
-   E_Input_Evdev *evdev;
    E_Input_Backend *input;
    Ecore_Event_Mouse_Button *ev;
    enum libinput_button_state state;
@@ -1153,10 +1140,8 @@ _device_handle_button(struct libinput_device *device, struct libinput_event_poin
    E_Comp_Config *comp_conf = NULL;
    const char *device_name = NULL;
 
-   if (!(evdev = libinput_device_get_user_data(device)))
-     {
-        return;
-     }
+   EINA_SAFETY_ON_NULL_RETURN(evdev);
+
    if (!(input = evdev->seat->input))
      {
         return;
@@ -1356,10 +1341,9 @@ _axis_value_get(struct libinput_event_pointer *pointer_event, enum libinput_poin
    return ret;
 }
 
-static void
-_device_handle_axis(struct libinput_device *device, struct libinput_event_pointer *event)
+EINTERN void
+e_input_evdev_handle_axis(E_Input_Evdev *evdev, struct libinput_event_pointer *event)
 {
-   E_Input_Evdev *evdev;
    E_Input_Backend *input;
    Ecore_Event_Mouse_Wheel *ev;
    uint32_t timestamp;
@@ -1370,10 +1354,8 @@ _device_handle_axis(struct libinput_device *device, struct libinput_event_pointe
    int direction = 0, z = 0;
    const char *device_name = NULL;
 
-   if (!(evdev = libinput_device_get_user_data(device)))
-     {
-        return;
-     }
+   EINA_SAFETY_ON_NULL_RETURN(evdev);
+
    if (!(input = evdev->seat->input))
      {
         return;
@@ -1497,7 +1479,7 @@ _scroll_value_get(struct libinput_event_pointer *pointer_event, enum libinput_po
 {
    double value = 0.0;
    double value_v120 = 0.0;
-   int ret;
+   int ret = 0;
    E_Comp_Config *comp_conf = NULL;
 
    comp_conf = e_comp_config_get();
@@ -1541,10 +1523,9 @@ _scroll_value_get(struct libinput_event_pointer *pointer_event, enum libinput_po
    return ret;
 }
 
-static void
-_device_handle_axis_v120(struct libinput_device *device, struct libinput_event_pointer *event, E_Input_Evdev_Axis_Source source)
+EINTERN void
+e_input_evdev_handle_axis_v120(E_Input_Evdev *evdev, struct libinput_event_pointer *event, E_Input_Evdev_Axis_Source source)
 {
-   E_Input_Evdev *evdev;
    E_Input_Backend *input;
    Ecore_Event_Mouse_Wheel *ev;
    uint32_t timestamp;
@@ -1555,10 +1536,8 @@ _device_handle_axis_v120(struct libinput_device *device, struct libinput_event_p
    int direction = 0, z = 0;
    const char *device_name = NULL;
 
-   if (!(evdev = libinput_device_get_user_data(device)))
-     {
-        return;
-     }
+   EINA_SAFETY_ON_NULL_RETURN(evdev);
+
    if (!(input = evdev->seat->input))
      {
         return;
@@ -2008,17 +1987,13 @@ _device_configured_size_get(E_Input_Evdev *evdev, int *x, int *y, int *w, int *h
    if (h) *h = evdev->mouse.maxh;
 }
 
-static void
-_device_handle_touch_down(struct libinput_device *device, struct libinput_event_touch *event)
+EINTERN void
+e_input_evdev_handle_touch_down(E_Input_Evdev *evdev, struct libinput_event_touch *event)
 {
-   E_Input_Evdev *evdev;
-   int x = 0, y = 0, w = 0, h = 0;
    E_Comp_Config *comp_conf = NULL;
+   int x = 0, y = 0, w = 0, h = 0;
 
-   if (!(evdev = libinput_device_get_user_data(device)))
-     {
-        return;
-     }
+   EINA_SAFETY_ON_NULL_RETURN(evdev);
 
    _device_configured_size_get(evdev, &x, &y, &w, &h);
 
@@ -2076,16 +2051,12 @@ _device_handle_touch_down(struct libinput_device *device, struct libinput_event_
    _device_handle_touch_event_send(evdev, event, ECORE_EVENT_MOUSE_BUTTON_DOWN);
 }
 
-static void
-_device_handle_touch_motion(struct libinput_device *device, struct libinput_event_touch *event)
+EINTERN void
+e_input_evdev_handle_touch_motion(E_Input_Evdev *evdev, struct libinput_event_touch *event)
 {
-   E_Input_Evdev *evdev;
    int x = 0, y = 0, w = 0, h = 0;
 
-   if (!(evdev = libinput_device_get_user_data(device)))
-     {
-        return;
-     }
+   EINA_SAFETY_ON_NULL_RETURN(evdev);
 
    _device_configured_size_get(evdev, &x, &y, &w, &h);
 
@@ -2144,16 +2115,12 @@ _device_handle_touch_motion(struct libinput_device *device, struct libinput_even
    _device_handle_touch_motion_send(evdev, event);
 }
 
-static void
-_device_handle_touch_up(struct libinput_device *device, struct libinput_event_touch *event)
+EINTERN void
+e_input_evdev_handle_touch_up(E_Input_Evdev *evdev, struct libinput_event_touch *event)
 {
-   E_Input_Evdev *evdev;
    E_Comp_Config *comp_conf = NULL;
 
-   if (!(evdev = libinput_device_get_user_data(device)))
-     {
-        return;
-     }
+   EINA_SAFETY_ON_NULL_RETURN(evdev);
 
    evdev->mt_slot = libinput_event_touch_get_slot(event);
    if (evdev->mt_slot < 0)
@@ -2223,16 +2190,12 @@ _device_handle_touch_up(struct libinput_device *device, struct libinput_event_to
    _device_handle_touch_event_send(evdev, event, ECORE_EVENT_MOUSE_BUTTON_UP);
 }
 
-static void
-_device_handle_touch_cancel(struct libinput_device *device, struct libinput_event_touch *event)
+EINTERN void
+e_input_evdev_handle_touch_cancel(E_Input_Evdev *evdev, struct libinput_event_touch *event)
 {
-   E_Input_Evdev *evdev;
    E_Comp_Config *comp_conf = NULL;
 
-   if (!(evdev = libinput_device_get_user_data(device)))
-     {
-        return;
-     }
+   EINA_SAFETY_ON_NULL_RETURN(evdev);
 
    evdev->mt_slot = libinput_event_touch_get_slot(event);
    if (evdev->mt_slot < 0)
@@ -2259,8 +2222,8 @@ _device_handle_touch_cancel(struct libinput_device *device, struct libinput_even
 }
 
 
-static void
-_device_handle_touch_frame(struct libinput_device *device EINA_UNUSED, struct libinput_event_touch *event EINA_UNUSED)
+EINTERN void
+e_input_evdev_handle_touch_frame(E_Input_Evdev *evdev EINA_UNUSED, struct libinput_event_touch *event EINA_UNUSED)
 {
    /* DBG("Unhandled Touch Frame Event"); */
 }
@@ -2276,10 +2239,9 @@ _e_input_aux_data_event_free(void *user_data EINA_UNUSED, void *ev)
    free(e);
 }
 
-static void
-_device_handle_touch_aux_data(struct libinput_device *device, struct libinput_event_touch_aux_data *event)
+EINTERN void
+e_input_edev_handle_touch_aux_data(E_Input_Evdev *evdev, struct libinput_event_touch_aux_data *event)
 {
-   E_Input_Evdev *evdev;
    E_Input_Backend *input;
    Ecore_Event_Axis_Update *ev;
    Ecore_Axis *axis;
@@ -2289,11 +2251,12 @@ _device_handle_touch_aux_data(struct libinput_device *device, struct libinput_ev
    uint32_t timestamp = 0;
    int touch_value;
 
+   EINA_SAFETY_ON_NULL_RETURN(evdev);
+
    if (libinput_event_touch_aux_data_get_type(event) != LIBINPUT_TOUCH_AUX_DATA_TYPE_PALM &&
        libinput_event_touch_aux_data_get_value(event) > 0)
       return;
 
-   if (!(evdev = libinput_device_get_user_data(device))) return;
    if (!(input = evdev->seat->input)) return;
 
    timestamp = libinput_event_touch_aux_data_get_time(event);
@@ -2500,72 +2463,6 @@ e_input_seat_evdev_list_get(E_Input_Seat *seat)
    return seat->devices;
 }
 
-Eina_Bool
-e_input_evdev_event_process(struct libinput_event *event)
-{
-   struct libinput_device *device;
-   Eina_Bool ret = EINA_TRUE;
-
-   device = libinput_event_get_device(event);
-   switch (libinput_event_get_type(event))
-     {
-      case LIBINPUT_EVENT_KEYBOARD_KEY:
-        _device_handle_key(device, libinput_event_get_keyboard_event(event));
-        break;
-      case LIBINPUT_EVENT_POINTER_MOTION:
-        _device_handle_pointer_motion(device,
-                                      libinput_event_get_pointer_event(event));
-        break;
-      case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
-        _device_handle_pointer_motion_absolute(device,
-                                               libinput_event_get_pointer_event(event));
-        break;
-      case LIBINPUT_EVENT_POINTER_BUTTON:
-        _device_handle_button(device, libinput_event_get_pointer_event(event));
-        break;
-      case LIBINPUT_EVENT_POINTER_AXIS:
-#if !LIBINPUT_HAVE_SCROLL_VALUE_V120
-        _device_handle_axis(device, libinput_event_get_pointer_event(event));
-#endif
-        break;
-#if LIBINPUT_HAVE_SCROLL_VALUE_V120
-      case LIBINPUT_EVENT_POINTER_SCROLL_WHEEL:
-        _device_handle_axis_v120(device, libinput_event_get_pointer_event(event), E_INPUT_EVDEV_AXIS_SOURCE_WHEEL);
-        break;
-      case LIBINPUT_EVENT_POINTER_SCROLL_FINGER:
-        _device_handle_axis_v120(device, libinput_event_get_pointer_event(event), E_INPUT_EVDEV_AXIS_SOURCE_FINGER);
-        break;
-      case LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS:
-        _device_handle_axis_v120(device, libinput_event_get_pointer_event(event), E_INPUT_EVDEV_AXIS_SOURCE_CONTINUOUS);
-        break;
-#endif
-      case LIBINPUT_EVENT_TOUCH_DOWN:
-        _device_handle_touch_down(device, libinput_event_get_touch_event(event));
-        break;
-      case LIBINPUT_EVENT_TOUCH_MOTION:
-        _device_handle_touch_motion(device,
-                                    libinput_event_get_touch_event(event));
-        break;
-      case LIBINPUT_EVENT_TOUCH_UP:
-        _device_handle_touch_up(device, libinput_event_get_touch_event(event));
-        break;
-      case LIBINPUT_EVENT_TOUCH_CANCEL:
-        _device_handle_touch_cancel(device, libinput_event_get_touch_event(event));
-        break;
-      case LIBINPUT_EVENT_TOUCH_FRAME:
-        _device_handle_touch_frame(device, libinput_event_get_touch_event(event));
-        break;
-      case LIBINPUT_EVENT_TOUCH_AUX_DATA:
-        _device_handle_touch_aux_data(device, libinput_event_get_touch_aux_data(event));
-        break;
-      default:
-        ret = EINA_FALSE;
-        break;
-     }
-
-   return ret;
-}
-
 /**
  * @brief Set the axis size of the given device.
  *
index 09bfaae..c648039 100644 (file)
@@ -128,7 +128,6 @@ EINTERN void          e_input_evdev_axis_size_set(E_Input_Evdev *evdev, int w, i
 
 EINTERN void          e_input_evdev_pointer_motion_post(E_Input_Evdev *evdev);
 EINTERN void          e_input_evdev_device_calibration_set(E_Input_Evdev *evdev);
-EINTERN Eina_Bool     e_input_evdev_event_process(struct libinput_event *event);
 
 EINTERN Eina_Bool     e_input_evdev_key_remap_enable(E_Input_Evdev *evdev, Eina_Bool enable);
 EINTERN Eina_Bool     e_input_evdev_key_remap_set(E_Input_Evdev *evdev, int *from_keys, int *to_keys, int num);
@@ -142,4 +141,17 @@ EINTERN unsigned int  e_input_evdev_touch_pressed_get(E_Input_Evdev *evdev);
 EINTERN const char   *e_input_evdev_seatname_get(E_Input_Evdev *evdev);
 EINTERN Eina_Bool     e_input_evdev_seatname_set(E_Input_Evdev *evdev, const char *seatname);
 
+EINTERN void e_input_evdev_handle_key(E_Input_Evdev *evdev, struct libinput_event_keyboard *event);
+EINTERN void e_input_evdev_handle_pointer_motion(E_Input_Evdev *evdev, struct libinput_event_pointer *event);
+EINTERN void e_input_evdev_handle_pointer_motion_absolute(E_Input_Evdev *evdev, struct libinput_event_pointer *event);
+EINTERN void e_input_evdev_handle_button(E_Input_Evdev *evdev, struct libinput_event_pointer *event);
+EINTERN void e_input_evdev_handle_axis(E_Input_Evdev *evdev, struct libinput_event_pointer *event);
+EINTERN void e_input_evdev_handle_axis_v120(E_Input_Evdev *evdev, struct libinput_event_pointer *event, E_Input_Evdev_Axis_Source source);
+EINTERN void e_input_evdev_handle_touch_down(E_Input_Evdev *evdev, struct libinput_event_touch *event);
+EINTERN void e_input_evdev_handle_touch_motion(E_Input_Evdev *evdev, struct libinput_event_touch *event);
+EINTERN void e_input_evdev_handle_touch_up(E_Input_Evdev *evdev, struct libinput_event_touch *event);
+EINTERN void e_input_evdev_handle_touch_cancel(E_Input_Evdev *evdev, struct libinput_event_touch *event);
+EINTERN void e_input_evdev_handle_touch_frame(E_Input_Evdev *evdev, struct libinput_event_touch *event);
+EINTERN void e_input_edev_handle_touch_aux_data(E_Input_Evdev *evdev, struct libinput_event_touch_aux_data *event);
+
 #endif