e_input: Do not devide translation components by output's w/h of a matrix
[platform/upstream/enlightenment.git] / src / bin / e_input_evdev.c
index 1b22f3f..1386b92 100644 (file)
@@ -1,5 +1,16 @@
-#include "e.h"
-#include "e_input_private.h"
+#include "e_input_intern.h"
+#include "e_input_log.h"
+#include "e_input_event.h"
+#include "e_keyrouter_intern.h"
+#include "e_devicemgr_intern.h"
+#include "e_device_intern.h"
+#include "e_comp_screen_intern.h"
+#include "e_output_intern.h"
+
+#include <glib.h>
+#include <ctype.h>
+
+#define G_LIST_GET_DATA(list) ((list) ? (((GList *)(list))->data) : NULL)
 
 static void  _device_modifiers_update(E_Input_Evdev *edev);
 static void  _device_configured_size_get(E_Input_Evdev *edev, int *x, int *y, int *w, int *h);
@@ -32,7 +43,7 @@ _device_calibration_set(E_Input_Evdev *edev)
         edev->mouse.maxw = w;
         edev->mouse.maxh = h;
 
-        if (libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_POINTER))
+        if (edev->caps & E_INPUT_SEAT_POINTER)
           {
              edev->seat->ptr.dx = (double)(w / 2);
              edev->seat->ptr.dy = (double)(h / 2);
@@ -56,45 +67,42 @@ _device_calibration_set(E_Input_Evdev *edev)
 
 //LCOV_EXCL_START
 #ifdef _F_E_INPUT_ENABLE_DEVICE_CALIBRATION_
-   const char *sysname;
    float cal[6];
-   const char *device;
-   Eina_List *devices;
 
    if ((!libinput_device_config_calibration_has_matrix(edev->device)) ||
        (libinput_device_config_calibration_get_default_matrix(edev->device, cal) != 0))
      return;
 
-   sysname = libinput_device_get_sysname(edev->device);
-
-   devices = eeze_udev_find_by_subsystem_sysname("input", sysname);
-   if (eina_list_count(devices) < 1) return;
-
 #ifdef _F_E_INPUT_USE_WL_CALIBRATION_
    const char *vals;
    enum libinput_config_status status;
+   struct udev_device *udev_device = NULL;
 
-   EINA_LIST_FREE(devices, device)
+   udev_device = libinput_device_get_udev_device(edev->device);
+   if (!udev_device)
      {
-        vals = eeze_udev_syspath_get_property(device, "WL_CALIBRATION");
-        if ((!vals) ||
-            (sscanf(vals, "%f %f %f %f %f %f",
-                    &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
-          goto cont;
+        ERR("no udev_device");
+        return;
+     }
 
-        cal[2] /= w;
-        cal[5] /= h;
+   vals = udev_device_get_property_value(udev_device, "WL_CALIBRATION");
+   if ((!vals) ||
+       (sscanf(vals, "%f %f %f %f %f %f",
+               &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
+     {
+        udev_device_unref(udev_device);
+        return;
+     }
+   udev_device_unref(udev_device);
 
-        status =
-          libinput_device_config_calibration_set_matrix(edev->device, cal);
+   ELOGF("E_INPUT_EVDEV", "calibration_set cal[%lf %lf %lf %lf %lf %lf] (%d x %d)",
+         NULL, cal[0], cal[1], cal[2], cal[3], cal[4], cal[5], w, h);
 
-        if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
-          ERR("Failed to apply calibration");
+   status =
+     libinput_device_config_calibration_set_matrix(edev->device, cal);
 
-cont:
-        eina_stringshare_del(device);
-        continue;
-     }
+   if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
+     ERR("Failed to apply calibration");
 #endif//_F_E_INPUT_USE_WL_CALIBRATION_
 #endif//_F_E_INPUT_ENABLE_DEVICE_CALIBRATION_
 //LCOV_EXCL_STOP
@@ -108,6 +116,7 @@ _device_output_assign(E_Input_Evdev *edev, E_Input_Seat_Capabilities cap)
    Eina_List *l;
    Eina_Bool need_assign_output = EINA_FALSE;
    const char *output_name;
+   E_Output *output;
 
    if (!(edev->caps & cap)) return;
    if (edev->output_name) return; //already assigned
@@ -117,7 +126,8 @@ _device_output_assign(E_Input_Evdev *edev, E_Input_Seat_Capabilities cap)
    EINA_LIST_FOREACH(edev->seat->devices, l, ed)
      {
         if (!(ed->caps & cap)) continue;
-        if ((ed != edev) && (ed->output_name))
+        if (ed == edev) continue;
+        if (ed->output_name)
           {
              need_assign_output = EINA_FALSE;
              break;
@@ -126,7 +136,9 @@ _device_output_assign(E_Input_Evdev *edev, E_Input_Seat_Capabilities cap)
      }
    if (need_assign_output)
      {
-        output_name = e_output_output_id_get(e_output_find_by_index(last_output_idx));
+        output = e_output_find_by_index(last_output_idx);
+        if (!output || !output->info.connected) return;
+        output_name = e_output_output_id_get(output);
         if (output_name) edev->output_name = eina_stringshare_add(output_name);
         ELOGF("E_INPUT_EVDEV", "Device is assigned to output:%s", NULL, output_name);
      }
@@ -174,8 +186,7 @@ _device_touch_count_update(E_Input_Evdev *edev)
           }
      }
 
-   ei->touch_device_count++;
-   ELOGF("E_INPUT_EVDEV_TOUCH", "Touch device count is %d.\n", NULL, ei->touch_device_count);
+   ELOGF("E_INPUT_EVDEV_TOUCH", "Touch max count is %d.\n", NULL, ei->touch_max_count);
 }
 
 static void
@@ -381,7 +392,36 @@ _device_remapped_key_get(E_Input_Evdev *edev, int code)
    return code;
 }
 
-E_API Ecore_Device *
+EINTERN E_Device *
+e_input_evdev_get_e_device(const char *path, Ecore_Device_Class clas)
+{
+   const GList *dev_list = NULL;
+   const GList *l;
+   E_Device *dev = NULL;
+   const char *identifier;
+
+   if (!path) return NULL;
+
+   dev_list = e_device_list_get();
+   if (!dev_list) return NULL;
+
+   l = dev_list;
+   while (l)
+     {
+        dev = l->data;
+        if (!dev) continue;
+        identifier = e_device_identifier_get(dev);
+        if (!identifier) continue;
+        if ((e_device_class_get(dev) == clas) && !(strcmp(identifier, path)))
+          return dev;
+
+        l = g_list_next(l);
+     }
+
+   return NULL;
+}
+
+EINTERN Ecore_Device *
 e_input_evdev_get_ecore_device(const char *path, Ecore_Device_Class clas)
 {
    const Eina_List *dev_list = NULL;
@@ -415,6 +455,16 @@ _e_input_event_mouse_move_cb_free(void *data EINA_UNUSED, void *event)
 }
 
 static void
+_e_input_event_mouse_relative_move_cb_free(void *data EINA_UNUSED, void *event)
+{
+   Ecore_Event_Mouse_Relative_Move *ev = event;
+
+   if (ev->dev) ecore_device_unref(ev->dev);
+
+   free(ev);
+}
+
+static void
 _e_input_event_mouse_wheel_cb_free(void *data EINA_UNUSED, void *event)
 {
    Ecore_Event_Mouse_Wheel *ev = event;
@@ -439,7 +489,15 @@ _e_input_event_key_cb_free(void *data EINA_UNUSED, void *event)
 {
    Ecore_Event_Key *ev = event;
 
-   if (ev->dev) ecore_device_unref(ev->dev);
+   if (e_input_thread_mode_get())
+     {
+        if (ev->dev) g_object_unref(ev->dev);
+     }
+   else
+     {
+        if (ev->dev) ecore_device_unref(ev->dev);
+     }
+
    if (ev->data) E_FREE(ev->data);
 
    free(ev);
@@ -461,10 +519,14 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
    char *tmp = NULL, *compose = NULL;
    E_Keyrouter_Event_Data *key_data;
    Ecore_Device *ecore_dev = NULL, *data;
-   Eina_List *l, *l_next;
+   E_Device *e_dev = NULL, *e_dev_data;
+   Eina_List *l = NULL, *l_next = NULL;
+   GList *glist = NULL;
    E_Comp_Config *comp_conf = NULL;
    int *pressed_keycode = NULL, *idata = NULL;
    Eina_Bool dup_found = EINA_FALSE;
+   const char *device_name = NULL;
+   Ecore_Device_Subclass device_subclas = ECORE_DEVICE_SUBCLASS_NONE;
 
    if (!(edev = libinput_device_get_user_data(device)))
      {
@@ -476,28 +538,67 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
         return;
      }
 
-   if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
-   else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
+   if (!e_input_thread_mode_get())
      {
-        EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
+        if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
+        else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
           {
-             if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_KEYBOARD)
+             EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
                {
-                  ecore_dev = data;
-                  break;
+                  if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_KEYBOARD)
+                    {
+                       ecore_dev = data;
+                       break;
+                    }
                }
           }
+        else
+          {
+             edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_KEYBOARD);
+             ecore_dev = edev->ecore_dev;
+          }
+
+        if (!ecore_dev)
+          {
+             ERR("Failed to get source ecore device from event !\n");
+             return;
+          }
+
+        device_name = ecore_device_name_get(ecore_dev);
+        device_subclas = ecore_device_subclass_get(ecore_dev);
      }
    else
      {
-        edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_KEYBOARD);
-        ecore_dev = edev->ecore_dev;
-     }
+        if (edev->e_dev) e_dev = edev->e_dev;
+        else if (edev->e_dev_list && g_list_length(edev->e_dev_list) > 0)
+          {
+             glist = edev->e_dev_list;
+             while (glist)
+               {
+                  e_dev_data = glist->data;
+                  if (e_device_class_get(e_dev_data) == ECORE_DEVICE_CLASS_KEYBOARD)
+                    {
+                       e_dev = e_dev_data;
+                       break;
+                    }
 
-   if (!ecore_dev)
-     {
-        ERR("Failed to get source ecore device from event !\n");
-        return;
+                  glist = g_list_next(glist);
+               }
+          }
+        else
+          {
+             edev->e_dev = e_input_evdev_get_e_device(edev->path, ECORE_DEVICE_CLASS_KEYBOARD);
+             e_dev = edev->e_dev;
+          }
+
+        if (!e_dev)
+          {
+             ERR("Failed to get source e device from event !\n");
+             return;
+          }
+
+        device_name = e_device_name_get(e_dev);
+        device_subclas = e_device_subclass_get(e_dev);
      }
 
    timestamp = libinput_event_keyboard_get_time(event);
@@ -511,8 +612,9 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
         if ((edev->seat->dev->blocked & E_INPUT_SEAT_KEYBOARD) ||
             (edev->seat->dev->server_blocked & E_INPUT_SEAT_KEYBOARD))
           {
+             void *blocked_client = atomic_load(&edev->seat->dev->blocked_client);
              ELOGF("Key", "Press (keycode: %d, device: %s) is blocked by %p, server: 0x%x", NULL,
-                   code, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client,
+                   code, device_name, blocked_client,
                    edev->seat->dev->server_blocked);
              return;
           }
@@ -554,8 +656,9 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
           }
         if (!dup_found)
           {
+             void *blocked_client = atomic_load(&edev->seat->dev->blocked_client);
              ELOGF("Key", "Release (keycode: %d, device: %s) is blocked by %p", NULL,
-                   code, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client);
+                   code, device_name, blocked_client);
              return;
           }
      }
@@ -567,11 +670,25 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
         return;
      }
 
+   e_input_keyboard_grab_key_cb func = e_input_keyboard_grab_key_handler_get();
+   if (func)
+     {
+        if (e_devicemgr_keyboard_grab_subtype_is_grabbed(device_subclas))
+          {
+             if (!e_input_thread_mode_get())
+               func(code, state, timestamp, ecore_dev);
+             else
+               func(code, state, timestamp, e_dev);
+             return;
+          }
+     }
+
    xkb_state_update_key(edev->xkb.state, code,
                         (state ? XKB_KEY_DOWN : XKB_KEY_UP));
 
    /* get the keysym for this code */
    nsyms = xkb_key_get_syms(edev->xkb.state, code, &syms);
+
    if (nsyms == 1) sym = syms[0];
 
    /* If no keysym was found, name it "Keycode-NNN" */
@@ -653,16 +770,36 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
    _device_modifiers_update(edev);
 
    e->modifiers = edev->xkb.modifiers;
-   e->dev = ecore_device_ref(ecore_dev);
 
    comp_conf = e_comp_config_get();
+
    if (comp_conf && comp_conf->input_log_enable)
-     ELOGF("Key", "%s (keyname: %s, keycode: %d, device: %s)", NULL, state?"Press":"Release", e->keyname, e->keycode, ecore_device_name_get(e->dev));
+     ELOGF("Key", "%s (keyname: %s, keycode: %d, timestamp: %u, device: %s)", NULL, state?"Press":"Release", e->keyname, e->keycode, e->timestamp, device_name);
 
-   if (state)
-     ecore_event_add(ECORE_EVENT_KEY_DOWN, e, _e_input_event_key_cb_free, NULL);
+   if (e_config->key_input_ttrace_enable)
+     {
+        TRACE_INPUT_BEGIN(ECORE_EVENT_KEY:%s:%s:%u:%lld, state ? "PRESS" : "RELEASE", e->keyname, timestamp, (long long unsigned int)libinput_event_keyboard_get_time_usec(event));
+        ELOGF("INPUT", "ECORE_EVENT_KEY:%s:%s:%u:%lld|B|", NULL, state ? "PRESS" : "RELEASE", e->keyname, timestamp, (long long unsigned int)libinput_event_keyboard_get_time_usec(event));
+     }
+
+   _e_input_key_event_list_add(e);
+
+   if (e_input_thread_mode_get())
+     {
+        e->dev = (Eo *)g_object_ref(e_dev);
+        e_input_event_add(input->event_source, state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_input_event_key_cb_free, NULL);
+     }
    else
-     ecore_event_add(ECORE_EVENT_KEY_UP, e, _e_input_event_key_cb_free, NULL);
+     {
+        e->dev = ecore_device_ref(ecore_dev);
+        ecore_event_add(state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_input_event_key_cb_free, NULL);
+     }
+
+   if (e_config->key_input_ttrace_enable)
+     {
+        TRACE_INPUT_END();
+        ELOGF("INPUT", "ECORE_EVENT_KEY|E|", NULL);
+     }
 
    if (tmp) free(tmp);
 }
@@ -678,6 +815,8 @@ _device_pointer_motion(E_Input_Evdev *edev, struct libinput_event_pointer *event
 
    if (!(input = edev->seat->input)) return;
 
+   ecore_thread_main_loop_begin();
+
    if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
    else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
      {
@@ -707,12 +846,12 @@ _device_pointer_motion(E_Input_Evdev *edev, struct libinput_event_pointer *event
    if (!ecore_dev)
      {
         ERR("Failed to get source ecore device from event !\n");
-        return;
+        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. */
-        return;
+        goto end;
      }
 
    if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
@@ -756,9 +895,13 @@ _device_pointer_motion(E_Input_Evdev *edev, struct libinput_event_pointer *event
    ev->multi.y = ev->y;
    ev->multi.root.x = ev->x;
    ev->multi.root.y = ev->y;
+
    ev->dev = ecore_device_ref(ecore_dev);
 
    ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _e_input_event_mouse_move_cb_free, NULL);
+
+end:
+   ecore_thread_main_loop_end();
 }
 
 void
@@ -768,52 +911,157 @@ _e_input_pointer_motion_post(E_Input_Evdev *edev)
 }
 
 static void
-_device_handle_pointer_motion(struct libinput_device *device, struct libinput_event_pointer *event)
+_device_pointer_relative_motion(E_Input_Evdev *edev, struct libinput_event_pointer *event, double dx[2], double dy[2])
 {
-   E_Input_Evdev *edev;
-   double dx, dy, temp;
+   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;
 
-   if (!(edev = libinput_device_get_user_data(device)))
+   if (!(input = edev->seat->input)) return;
+
+   ecore_thread_main_loop_begin();
+
+   if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
+   else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
      {
-        return;
+        EINA_LIST_FOREACH(edev->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(libinput_device_get_name(edev->device)))
+          {
+             ecore_dev = detent_data;
+          }
+     }
+   else
+     {
+        edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
+        ecore_dev = edev->ecore_dev;
      }
 
-   dx = libinput_event_pointer_get_dx(event);
-   dy = libinput_event_pointer_get_dy(event);
-
-   if (edev->seat->ptr.swap)
+   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)))
      {
-         temp = dx;
-         dx = dy;
-         dy = temp;
+        /* Do not process detent device's move events. */
+        goto end;
      }
-   if (edev->seat->ptr.invert_x)
-     dx *= -1;
-   if (edev->seat->ptr.invert_y)
-     dy *= -1;
 
-   edev->seat->ptr.dx += dx;
-   edev->seat->ptr.dy += dy;
+   if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Relative_Move)))) return;
 
-   edev->mouse.dx = edev->seat->ptr.dx;
-   edev->mouse.dy = edev->seat->ptr.dy;
+   ev->window = (Ecore_Window)input->dev->window;
+   ev->event_window = (Ecore_Window)input->dev->window;
+   if (event) ev->timestamp = libinput_event_pointer_get_time(event);
 
-   if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
-       floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
+   ev->modifiers = edev->xkb.modifiers;
+
+   ev->dx = (int)dx[0];
+   ev->dy = (int)dy[0];
+   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: %d, dy: %d, unaccel(%d, %d) device: %s)", NULL, ev->timestamp, ev->dx, ev->dy, ev->dx_unaccel, ev->dy_unaccel, ecore_device_name_get(ev->dev));
+
+   ecore_event_add(ECORE_EVENT_MOUSE_RELATIVE_MOVE, ev, _e_input_event_mouse_relative_move_cb_free, NULL);
+
+end:
+   ecore_thread_main_loop_end();
+}
+
+static void
+_device_pointer_motion_send(E_Input_Evdev *edev, struct libinput_event_pointer *event, double dx[2], double dy[2])
+{
+   e_input_relative_motion_cb func = e_input_relative_motion_handler_get();
+   if (func)
      {
-        return;
+        //func(dx, dy, time_us);
+        _device_pointer_relative_motion(edev, event, dx, dy);
      }
+   else
+     {
+        double seat_dx, seat_dy, temp;
+        if (edev->disable_acceleration)
+          {
+              seat_dx = dx[1];
+              seat_dy = dy[1];
+          }
+        else
+          {
+              seat_dx = dx[0];
+              seat_dy = dy[0];
+          }
 
-   edev->seat->ptr.ix = edev->seat->ptr.dx;
-   edev->seat->ptr.iy = edev->seat->ptr.dy;
+        if (edev->seat->ptr.swap)
+          {
+              temp = seat_dx;
+              seat_dx = seat_dy;
+              seat_dy = temp;
+          }
+        if (edev->seat->ptr.invert_x)
+          seat_dx *= -1;
+        if (edev->seat->ptr.invert_y)
+          seat_dy *= -1;
 
-   if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
-       (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
+        edev->seat->ptr.dx += seat_dx;
+        edev->seat->ptr.dy += seat_dy;
+
+        edev->mouse.dx = edev->seat->ptr.dx;
+        edev->mouse.dy = edev->seat->ptr.dy;
+
+        if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
+            floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
+          {
+              return;
+          }
+
+        edev->seat->ptr.ix = edev->seat->ptr.dx;
+        edev->seat->ptr.iy = edev->seat->ptr.dy;
+
+        if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
+            (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
+          {
+              return;
+          }
+
+        _device_pointer_motion(edev, event);
+     }
+}
+
+static void
+_device_handle_pointer_motion(struct libinput_device *device, struct libinput_event_pointer *event)
+{
+   E_Input_Evdev *edev;
+   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 (!(edev = libinput_device_get_user_data(device)))
      {
         return;
      }
 
-  _device_pointer_motion(edev, event);
+   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);
+   delta_y[1] = libinput_event_pointer_get_dy_unaccelerated(event);
+
+   _device_pointer_motion_send(edev, event, &delta_x[0], &delta_y[0]);
 }
 
 static void
@@ -873,6 +1121,8 @@ _device_handle_button(struct libinput_device *device, struct libinput_event_poin
         return;
      }
 
+   ecore_thread_main_loop_begin();
+
    if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
    else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
      {
@@ -902,7 +1152,7 @@ _device_handle_button(struct libinput_device *device, struct libinput_event_poin
    if (!ecore_dev)
      {
         ERR("Failed to get source ecore device from event !\n");
-        return;
+        goto end;
      }
 
    state = libinput_event_pointer_get_button_state(event);
@@ -913,15 +1163,18 @@ _device_handle_button(struct libinput_device *device, struct libinput_event_poin
    if (button == 3) button = 2;
    else if (button == 2) button = 3;
 
+   void *blocked_client = atomic_load(&edev->seat->dev->blocked_client);
+
    if (state)
      {
         if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
             (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
           {
+
              ELOGF("Mouse", "Button Press (btn: %d, device: %s) is blocked by %p, server: 0x%x", NULL,
-                   button, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client,
+                   button, ecore_device_name_get(ecore_dev), blocked_client,
                    edev->seat->dev->server_blocked);
-             return;
+             goto end;
           }
         else
           {
@@ -933,16 +1186,16 @@ _device_handle_button(struct libinput_device *device, struct libinput_event_poin
         if (!(edev->mouse.pressed_button & (1 << button)))
           {
              ELOGF("Mouse", "Button Release (btn: %d, device: %s) is blocked by %p, server: 0x%x", NULL,
-                   button, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client,
+                   button, ecore_device_name_get(ecore_dev), blocked_client,
                    edev->seat->dev->server_blocked);
-             return;
+             goto end;
           }
         edev->mouse.pressed_button &= ~(1 << button);
      }
 
    if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button))))
      {
-        return;
+        goto end;
      }
 
    ev->window = (Ecore_Window)input->dev->window;
@@ -1014,6 +1267,52 @@ _device_handle_button(struct libinput_device *device, struct libinput_event_poin
      ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, _e_input_event_mouse_button_cb_free, NULL);
    else
      ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, _e_input_event_mouse_button_cb_free, NULL);
+
+end:
+   ecore_thread_main_loop_end();
+}
+
+#if !LIBINPUT_HAVE_SCROLL_VALUE_V120
+static int
+_axis_value_get(struct libinput_event_pointer *pointer_event, enum libinput_pointer_axis axis)
+{
+   enum libinput_pointer_axis_source source;
+   double value = 0.0, value_discrete = 0.0;
+   int ret = 0;
+   E_Comp_Config *comp_conf = NULL;
+
+   comp_conf = e_comp_config_get();
+   source = libinput_event_pointer_get_axis_source(pointer_event);
+   switch (source)
+     {
+      case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL:
+        value_discrete = libinput_event_pointer_get_axis_value_discrete(pointer_event, axis);
+        value = libinput_event_pointer_get_axis_value(pointer_event, axis);
+        if (comp_conf && comp_conf->input_log_enable)
+          {
+             ELOGF("Axis", "SOURCE_WHEEL discrete: %lf (cf. value: %lf)", NULL, value_discrete, value);
+          }
+        ret = (int)value_discrete;
+        break;
+      case LIBINPUT_POINTER_AXIS_SOURCE_FINGER:
+      case LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS:
+        value = libinput_event_pointer_get_axis_value(pointer_event, axis);
+        if (comp_conf && comp_conf->input_log_enable)
+          {
+             ELOGF("Axis", "SOURCE_FINGER/CONTINUOUS value: %lf", NULL, value);
+          }
+        if (value >= E_INPUT_FINGER_SCROLL_THRESHOLD)
+          ret = 1;
+        else if (value <= E_INPUT_FINGER_SCROLL_THRESHOLD * (-1))
+          ret = -1;
+        else
+          ret = 0;
+        break;
+      default:
+        break;
+     }
+
+   return ret;
 }
 
 static void
@@ -1038,6 +1337,8 @@ _device_handle_axis(struct libinput_device *device, struct libinput_event_pointe
         return;
      }
 
+   ecore_thread_main_loop_begin();
+
    if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
    else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
      {
@@ -1067,20 +1368,26 @@ _device_handle_axis(struct libinput_device *device, struct libinput_event_pointe
    if (!ecore_dev)
      {
         ERR("Failed to get source ecore device from event !\n");
-        return;
+        goto end;
      }
 
    axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
    if (libinput_event_pointer_has_axis(event, axis))
-     z = libinput_event_pointer_get_axis_value_discrete(event, axis);
+     z = _axis_value_get(event, axis);
 
    axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
    if (libinput_event_pointer_has_axis(event, axis))
      {
         direction = 1;
-        z = libinput_event_pointer_get_axis_value_discrete(event, axis);
+        z = _axis_value_get(event, axis);
      }
 
+  if (z == 0)
+    {
+       ELOGF("Mouse", "Axis event is ignored since it has zero value", NULL);
+       goto end;
+    }
+
    comp_conf = e_comp_config_get();
    if (comp_conf && comp_conf->e_wheel_click_angle)
      {
@@ -1090,18 +1397,21 @@ _device_handle_axis(struct libinput_device *device, struct libinput_event_pointe
    if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
        (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
      {
+        void *blocked_client = atomic_load(&edev->seat->dev->blocked_client);
+
         if (detent_data)
           ELOGF("Mouse", "Detent (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL,
-                direction, z, edev->seat->dev->blocked_client, edev->seat->dev->server_blocked);
+                direction, z, blocked_client, edev->seat->dev->server_blocked);
         else
           ELOGF("Mouse", "Wheel (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL,
-                direction, z, edev->seat->dev->blocked_client, edev->seat->dev->server_blocked);
-        return;
+                direction, z, blocked_client, edev->seat->dev->server_blocked);
+
+        goto end;
      }
 
    if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel))))
      {
-        return;
+        goto end;
      }
 
    timestamp = libinput_event_pointer_get_time(event);
@@ -1119,8 +1429,189 @@ _device_handle_axis(struct libinput_device *device, struct libinput_event_pointe
    ev->y = edev->seat->ptr.iy;
    ev->root.x = ev->x;
    ev->root.y = ev->y;
+   ev->z = z;
+   ev->direction = direction;
+
+   if (comp_conf && comp_conf->input_log_enable)
+     {
+        if (detent_data)
+          ELOGF("Mouse", "Detent (direction: %d, value: %d)", NULL, ev->direction, ev->z);
+        else
+          ELOGF("Mouse", "Wheel (direction: %d, value: %d)", NULL, ev->direction, ev->z);
+     }
+
+
    ev->dev = ecore_device_ref(ecore_dev);
+   ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _e_input_event_mouse_wheel_cb_free, NULL);
+
+end:
+   ecore_thread_main_loop_end();
+}
+#endif
+
+#if LIBINPUT_HAVE_SCROLL_VALUE_V120
+static int
+_scroll_value_get(struct libinput_event_pointer *pointer_event, enum libinput_pointer_axis axis, E_Input_Axis_Source source)
+{
+   double value = 0.0;
+   double value_v120 = 0.0;
+   int ret;
+   E_Comp_Config *comp_conf = NULL;
+
+   comp_conf = e_comp_config_get();
+   switch (source)
+     {
+      case E_INPUT_AXIS_SOURCE_WHEEL:
+        value_v120 = libinput_event_pointer_get_scroll_value_v120(pointer_event, axis);
+        value = libinput_event_pointer_get_scroll_value(pointer_event, axis);
+        if (comp_conf && comp_conf->input_log_enable)
+          {
+             ELOGF("Scroll", "SOURCE_WHEEL value_v120: %lf (cf. value: %lf)", NULL, value_v120, value);
+          }
+        if (((int)value_v120 % E_INPUT_POINTER_AXIS_DISCRETE_STEP) != 0)
+          {
+             ERR("Wheel movements should be multiples (or fractions) of 120!\n");
+             ret = 0;
+          }
+        else
+          {
+             ret = value_v120 / E_INPUT_POINTER_AXIS_DISCRETE_STEP;
+          }
+        break;
+      case E_INPUT_AXIS_SOURCE_FINGER:
+      case E_INPUT_AXIS_SOURCE_CONTINUOUS:
+        value = libinput_event_pointer_get_scroll_value(pointer_event, axis);
+        if (comp_conf && comp_conf->input_log_enable)
+          {
+             ELOGF("Scroll", "SOURCE_FINGER/CONTINUOUS value: %lf", NULL, value);
+          }
+        if (value >= E_INPUT_FINGER_SCROLL_THRESHOLD)
+          ret = 1;
+        else if (value <= E_INPUT_FINGER_SCROLL_THRESHOLD * (-1))
+          ret = -1;
+        else
+          ret = 0;
+        break;
+      default:
+        break;
+     }
+
+   return ret;
+}
+
+static void
+_device_handle_axis_v120(struct libinput_device *device, struct libinput_event_pointer *event, E_Input_Axis_Source source)
+{
+   E_Input_Evdev *edev;
+   E_Input_Backend *input;
+   Ecore_Event_Mouse_Wheel *ev;
+   uint32_t timestamp;
+   enum libinput_pointer_axis axis;
+   Ecore_Device *ecore_dev = NULL, *detent_data = NULL, *data;
+   Eina_List *l;
+   E_Comp_Config *comp_conf = NULL;
+   int direction = 0, z = 0;
+
+   if (!(edev = libinput_device_get_user_data(device)))
+     {
+        return;
+     }
+   if (!(input = edev->seat->input))
+     {
+        return;
+     }
+
+   ecore_thread_main_loop_begin();
+
+   if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
+   else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
+     {
+        EINA_LIST_FOREACH(edev->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(libinput_device_get_name(edev->device)))
+          {
+             ecore_dev = detent_data;
+          }
+     }
+   else
+     {
+        edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
+        ecore_dev = edev->ecore_dev;
+     }
+
+   if (!ecore_dev)
+     {
+        ERR("Failed to get source ecore device from event !\n");
+        goto end;
+     }
+
+   axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
+   if (libinput_event_pointer_has_axis(event, axis))
+     z = _scroll_value_get(event, axis, source);
+
+   axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
+   if (libinput_event_pointer_has_axis(event, axis))
+     {
+        direction = 1;
+        z = _scroll_value_get(event, axis, source);
+     }
+
+   if (z == 0)
+     {
+        ELOGF("Mouse", "Scroll event is ignored since it has zero value", NULL);
+        goto end;
+     }
+
+   comp_conf = e_comp_config_get();
+   if (comp_conf && comp_conf->e_wheel_click_angle)
+     {
+        z = (int)(z * comp_conf->e_wheel_click_angle);
+     }
+
+   if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
+       (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
+     {
+        void *blocked_client = atomic_load(&edev->seat->dev->blocked_client);
+        if (detent_data)
+          ELOGF("Mouse", "Detent (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL,
+                direction, z, blocked_client, edev->seat->dev->server_blocked);
+        else
+          ELOGF("Mouse", "Wheel (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL,
+                direction, z, blocked_client, edev->seat->dev->server_blocked);
+
+        goto end;
+     }
+
+   if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel))))
+     {
+        goto end;
+     }
+
+   timestamp = libinput_event_pointer_get_time(event);
+
+   ev->window = (Ecore_Window)input->dev->window;
+   ev->event_window = (Ecore_Window)input->dev->window;
+   ev->root_window = (Ecore_Window)input->dev->window;
+   ev->timestamp = timestamp;
+   ev->same_screen = 1;
 
+   _device_modifiers_update(edev);
+   ev->modifiers = edev->xkb.modifiers;
+
+   ev->x = edev->seat->ptr.ix;
+   ev->y = edev->seat->ptr.iy;
+   ev->root.x = ev->x;
+   ev->root.y = ev->y;
    ev->z = z;
    ev->direction = direction;
 
@@ -1132,8 +1623,13 @@ _device_handle_axis(struct libinput_device *device, struct libinput_event_pointe
           ELOGF("Mouse", "Wheel (direction: %d, value: %d)", NULL, ev->direction, ev->z);
      }
 
+   ev->dev = ecore_device_ref(ecore_dev);
    ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _e_input_event_mouse_wheel_cb_free, NULL);
+
+end:
+   ecore_thread_main_loop_end();
 }
+#endif
 
 static void
 _device_handle_touch_event_send(E_Input_Evdev *edev, struct libinput_event_touch *event, int state)
@@ -1147,6 +1643,8 @@ _device_handle_touch_event_send(E_Input_Evdev *edev, struct libinput_event_touch
    if (!edev) return;
    if (!(input = edev->seat->input)) return;
 
+   ecore_thread_main_loop_begin();
+
    if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
    else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
      {
@@ -1168,10 +1666,10 @@ _device_handle_touch_event_send(E_Input_Evdev *edev, struct libinput_event_touch
    if (!ecore_dev)
      {
         ERR("Failed to get source ecore device from event !\n");
-        return;
+        goto end;
      }
 
-   if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) return;
+   if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) goto end;
 
    timestamp = libinput_event_touch_get_time(event);
 
@@ -1256,6 +1754,9 @@ _device_handle_touch_event_send(E_Input_Evdev *edev, struct libinput_event_touch
      ev->triple_click = 1;
 
    ecore_event_add(state, ev, _e_input_event_mouse_button_cb_free, NULL);
+
+end:
+   ecore_thread_main_loop_end();
 }
 
 static void
@@ -1269,6 +1770,8 @@ _device_handle_touch_motion_send(E_Input_Evdev *edev, struct libinput_event_touc
    if (!edev) return;
    if (!(input = edev->seat->input)) return;
 
+   ecore_thread_main_loop_begin();
+
    if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
    else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
      {
@@ -1290,10 +1793,10 @@ _device_handle_touch_motion_send(E_Input_Evdev *edev, struct libinput_event_touc
    if (!ecore_dev)
      {
         ERR("Failed to get source ecore device from event !\n");
-        return;
+        goto end;
      }
 
-   if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
+   if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) goto end;
 
    ev->window = (Ecore_Window)input->dev->window;
    ev->event_window = (Ecore_Window)input->dev->window;
@@ -1332,6 +1835,9 @@ _device_handle_touch_motion_send(E_Input_Evdev *edev, struct libinput_event_touc
    ev->dev = ecore_device_ref(ecore_dev);
 
    ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _e_input_event_mouse_move_cb_free, NULL);
+
+end:
+   ecore_thread_main_loop_end();
 }
 
 static void
@@ -1346,6 +1852,8 @@ _device_handle_touch_cancel_send(E_Input_Evdev *edev, struct libinput_event_touc
    if (!edev) return;
    if (!(input = edev->seat->input)) return;
 
+   ecore_thread_main_loop_begin();
+
    if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
    else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
      {
@@ -1367,10 +1875,10 @@ _device_handle_touch_cancel_send(E_Input_Evdev *edev, struct libinput_event_touc
    if (!ecore_dev)
      {
         ERR("Failed to get source ecore device from event !\n");
-        return;
+        goto end;
      }
 
-   if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) return;
+   if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) goto end;
 
    timestamp = libinput_event_touch_get_time(event);
 
@@ -1395,13 +1903,16 @@ _device_handle_touch_cancel_send(E_Input_Evdev *edev, struct libinput_event_touc
    ev->multi.y = ev->y;
    ev->multi.root.x = ev->x;
    ev->multi.root.y = ev->y;
-   ev->dev = ecore_device_ref(ecore_dev);
 
    edev->touch.pressed &= ~(1 << ev->multi.device);
 
    ev->buttons = ((button & 0x00F) + 1);
+   ev->dev = ecore_device_ref(ecore_dev);
 
    ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, ev, _e_input_event_mouse_button_cb_free, NULL);
+
+end:
+   ecore_thread_main_loop_end();
 }
 
 static void
@@ -1422,7 +1933,7 @@ _device_configured_size_get(E_Input_Evdev *edev, int *x, int *y, int *w, int *h)
                   edev->mouse.miny = output->config.geom.y;
                   edev->mouse.maxw = output->config.geom.w;
                   edev->mouse.maxh = output->config.geom.h;
-                  if (libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_POINTER))
+                  if (edev->caps & E_INPUT_SEAT_POINTER)
                     {
                        edev->seat->ptr.dx = (double)(edev->mouse.maxw / 2);
                        edev->seat->ptr.dy = (double)(edev->mouse.maxh / 2);
@@ -1490,12 +2001,13 @@ _device_handle_touch_down(struct libinput_device *device, struct libinput_event_
    if (comp_conf && comp_conf->input_log_enable)
      ELOGF("Touch", "Down (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy);
 
-   edev->touch.raw_pressed |= (1 << edev->mt_slot);
+   atomic_fetch_or(&edev->touch.raw_pressed, (1 << edev->mt_slot));
 
    if (edev->touch.blocked)
      {
+        void *blocked_client = atomic_load(&edev->seat->dev->blocked_client);
         ELOGF("Touch", "Down (id: %d, x: %d, y: %d) is blocked by %p, server: 0x%x", NULL,
-              edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy, edev->seat->dev->blocked_client,
+              edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy, blocked_client,
               edev->seat->dev->server_blocked);
         return;
      }
@@ -1605,15 +2117,17 @@ _device_handle_touch_up(struct libinput_device *device, struct libinput_event_to
    if (comp_conf && comp_conf->input_log_enable)
      ELOGF("Touch", "Up (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy);
 
-   edev->touch.raw_pressed &= ~(1 << edev->mt_slot);
+   atomic_fetch_and(&edev->touch.raw_pressed, ~(1 << edev->mt_slot));
 
    if (edev->touch.blocked)
      {
         if (!(edev->touch.pressed & (1 << edev->mt_slot)))
           {
+             void *blocked_client = atomic_load(&edev->seat->dev->blocked_client);
              ELOGF("Touch", "Up (id: %d, x: %d, y: %d) is blocked by %p, server(0x%x)", NULL,
-                   edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy, edev->seat->dev->blocked_client,
+                   edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy, blocked_client,
                    edev->seat->dev->server_blocked);
+
              if (edev->touch.raw_pressed == 0x0)
                {
                   edev->touch.blocked = EINA_FALSE;
@@ -1689,6 +2203,8 @@ _device_handle_touch_aux_data(struct libinput_device *device, struct libinput_ev
    Eina_List *l;
    E_Comp_Config *comp_conf;
 
+   ecore_thread_main_loop_begin();
+
    if (libinput_event_touch_aux_data_get_type(event) != LIBINPUT_TOUCH_AUX_DATA_TYPE_PALM &&
        libinput_event_touch_aux_data_get_value(event) > 0)
       goto end;
@@ -1720,7 +2236,7 @@ _device_handle_touch_aux_data(struct libinput_device *device, struct libinput_ev
         goto end;
      }
 
-   if (!(ev = calloc(1, sizeof(Ecore_Event_Axis_Update))))goto end;
+   if (!(ev = calloc(1, sizeof(Ecore_Event_Axis_Update)))) goto end;
 
    ev->window = (Ecore_Window)input->dev->window;
    ev->event_window = (Ecore_Window)input->dev->window;
@@ -1735,16 +2251,17 @@ _device_handle_touch_aux_data(struct libinput_device *device, struct libinput_ev
         ev->naxis = 1;
      }
    ev->axis = axis;
-   ev->dev = ecore_device_ref(ecore_dev);
 
    comp_conf = e_comp_config_get();
    if (comp_conf && comp_conf->input_log_enable)
      ELOGF("Touch", "Axis (label: %d, value: %lf)", NULL, axis?axis->label:-1, axis?axis->value:0.0);
 
+   ev->dev = ecore_device_ref(ecore_dev);
+
    ecore_event_add(ECORE_EVENT_AXIS_UPDATE, ev, _e_input_aux_data_event_free, NULL);
 
 end:
-   ;
+   ecore_thread_main_loop_end();
 }
 
 E_Input_Evdev *
@@ -1826,12 +2343,14 @@ void
 _e_input_evdev_device_destroy(E_Input_Evdev *edev)
 {
    Ecore_Device *dev;
-
    EINA_SAFETY_ON_NULL_RETURN(edev);
 
+   ecore_thread_main_loop_begin();
+
    if (edev->caps & E_INPUT_SEAT_KEYBOARD)
      {
         if (edev->xkb.state) xkb_state_unref(edev->xkb.state);
+
         if (edev->xkb.keymap) xkb_map_unref(edev->xkb.keymap);
      }
 
@@ -1841,6 +2360,20 @@ _e_input_evdev_device_destroy(E_Input_Evdev *edev)
        {
           ecore_device_del(dev);
        }
+
+   if (edev->e_dev) g_object_unref(edev->e_dev);
+   if (edev->e_dev_list)
+     {
+        GList *glist = edev->e_dev_list;
+        E_Device *e_dev;
+        while (glist)
+          {
+             e_dev = glist->data;
+             g_object_unref(e_dev);
+
+             glist = g_list_next(glist);
+          }
+     }
    if (edev->path) eina_stringshare_del(edev->path);
    if (edev->device) libinput_device_unref(edev->device);
    if (edev->key_remap_hash) eina_hash_free(edev->key_remap_hash);
@@ -1851,6 +2384,8 @@ _e_input_evdev_device_destroy(E_Input_Evdev *edev)
      }
    eina_stringshare_del(edev->output_name);
 
+   ecore_thread_main_loop_end();
+
    free(edev);
 }
 
@@ -1878,8 +2413,21 @@ _e_input_evdev_event_process(struct libinput_event *event)
         _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_AXIS_SOURCE_WHEEL);
+        break;
+      case LIBINPUT_EVENT_POINTER_SCROLL_FINGER:
+        _device_handle_axis_v120(device, libinput_event_get_pointer_event(event), E_INPUT_AXIS_SOURCE_FINGER);
         break;
+      case LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS:
+        _device_handle_axis_v120(device, libinput_event_get_pointer_event(event), E_INPUT_AXIS_SOURCE_CONTINUOUS);
+        break;
+#endif
       case LIBINPUT_EVENT_TOUCH_DOWN:
         _device_handle_touch_down(device, libinput_event_get_touch_event(event));
         break;
@@ -1922,12 +2470,10 @@ _e_input_evdev_event_process(struct libinput_event *event)
 EINTERN void
 e_input_evdev_axis_size_set(E_Input_Evdev *edev, int w, int h)
 {
-   const char *sysname;
    float cal[6];
-   const char *device;
-   Eina_List *devices;
    const char *vals;
    enum libinput_config_status status;
+   struct udev_device *udev_device = NULL;
 
    EINA_SAFETY_ON_NULL_RETURN(edev);
    EINA_SAFETY_ON_TRUE_RETURN((w == 0) || (h == 0));
@@ -1936,35 +2482,37 @@ e_input_evdev_axis_size_set(E_Input_Evdev *edev, int w, int h)
        (libinput_device_config_calibration_get_default_matrix(edev->device, cal) != 0))
      return;
 
-   sysname = libinput_device_get_sysname(edev->device);
-
-   devices = eeze_udev_find_by_subsystem_sysname("input", sysname);
-   if (eina_list_count(devices) < 1) return;
+   udev_device = libinput_device_get_udev_device(edev->device);
+   if (!udev_device)
+     {
+        ERR("no udev_device");
+        return;
+     }
 
-   EINA_LIST_FREE(devices, device)
+   vals = udev_device_get_property_value(udev_device, "WL_CALIBRATION");
+   if ((!vals) ||
+       (sscanf(vals, "%f %f %f %f %f %f",
+               &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
      {
-        vals = eeze_udev_syspath_get_property(device, "WL_CALIBRATION");
-       if ((!vals) ||
-            (sscanf(vals, "%f %f %f %f %f %f",
-                    &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
-          goto cont;
+        udev_device_unref(udev_device);
+        return;
+     }
+   udev_device_unref(udev_device);
 
-        cal[2] /= w;
-        cal[5] /= h;
+   ELOGF("E_INPUT_EVDEV", "axis_size_set cal[%lf %lf %lf %lf %lf %lf] (%d x %d)",
+         NULL, cal[0], cal[1], cal[2], cal[3], cal[4], cal[5], w, h);
 
-        status =
-          libinput_device_config_calibration_set_matrix(edev->device, cal);
+   cal[2] /= w;
+   cal[5] /= h;
 
-        if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
-          ERR("Failed to apply calibration");
+   status =
+     libinput_device_config_calibration_set_matrix(edev->device, cal);
 
-cont:
-        eina_stringshare_del(device);
-        continue;
-     }
+   if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
+     ERR("Failed to apply calibration");
 }
 
-E_API const char *
+EINTERN const char *
 e_input_evdev_name_get(E_Input_Evdev *evdev)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, NULL);
@@ -2037,7 +2585,7 @@ e_input_evdev_key_remap_set(E_Input_Evdev *edev, int *from_keys, int *to_keys, i
    return EINA_TRUE;
 }
 
-E_API int
+EINTERN int
 e_input_evdev_wheel_click_angle_get(E_Input_Evdev *dev)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(dev, -1);
@@ -2122,9 +2670,11 @@ e_input_evdev_seatname_set(E_Input_Evdev *evdev, const char *seatname)
      {
         input = evdev->seat->input;
         if (!input) return EINA_FALSE;
+
         if (libinput_dispatch(input->libinput) != 0)
           {
              ERR("Failed to dispatch libinput events: %m");
+
              return EINA_FALSE;
           }
 
@@ -2134,4 +2684,4 @@ e_input_evdev_seatname_set(E_Input_Evdev *evdev, const char *seatname)
      }
 
    return res;
-}
\ No newline at end of file
+}