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 8a08e02..1386b92 100644 (file)
@@ -1,10 +1,14 @@
-#include "e.h"
-#include "e_input_private.h"
-#include "e_device.h"
-#include "e_keyrouter_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)
 
@@ -39,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);
@@ -63,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
@@ -185,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
@@ -213,31 +213,21 @@ _device_keyboard_setup(E_Input_Evdev *edev)
    if (!(input = edev->seat->input)) return;
    if (!input->dev->xkb_ctx) return;
 
-   g_mutex_init(&edev->xkb.keymap_mutex);
-
    /* create keymap from xkb context */
-   g_mutex_lock(&edev->xkb.keymap_mutex);
    edev->xkb.keymap = _e_input_device_cached_keymap_get(input->dev->xkb_ctx, NULL, 0);
    if (!edev->xkb.keymap)
      {
-        g_mutex_unlock(&edev->xkb.keymap_mutex);
         ERR("Failed to create keymap: %m");
         return;
      }
 
-   g_mutex_lock(&edev->xkb.state_mutex);
-
    /* create xkb state */
    if (!(edev->xkb.state = xkb_state_new(edev->xkb.keymap)))
      {
-        g_mutex_unlock(&edev->xkb.state_mutex);
-        g_mutex_unlock(&edev->xkb.keymap_mutex);
         ERR("Failed to create xkb state: %m");
         return;
      }
 
-   g_mutex_unlock(&edev->xkb.state_mutex);
-
    xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_CTRL);
    if (xkb_idx != XKB_MOD_INVALID)
      edev->xkb.ctrl_mask = 1 << xkb_idx;
@@ -285,8 +275,6 @@ _device_keyboard_setup(E_Input_Evdev *edev)
      edev->xkb.altgr_mask = 1 << xkb_idx;
    else
      edev->xkb.altgr_mask = 0;
-
-   g_mutex_unlock(&edev->xkb.keymap_mutex);
 }
 
 static int
@@ -338,8 +326,6 @@ _device_modifiers_update_device(E_Input_Evdev *edev, E_Input_Evdev *from)
 {
    xkb_mod_mask_t mask;
 
-   g_mutex_lock(&from->xkb.state_mutex);
-
    edev->xkb.depressed =
      xkb_state_serialize_mods(from->xkb.state, XKB_STATE_DEPRESSED);
    edev->xkb.latched =
@@ -349,8 +335,6 @@ _device_modifiers_update_device(E_Input_Evdev *edev, E_Input_Evdev *from)
    edev->xkb.group =
      xkb_state_serialize_mods(from->xkb.state, XKB_STATE_EFFECTIVE);
 
-   g_mutex_unlock(&from->xkb.state_mutex);
-
    mask = (edev->xkb.depressed | edev->xkb.latched);
 
    if (mask & from->xkb.ctrl_mask)
@@ -471,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;
@@ -531,7 +525,8 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
    E_Comp_Config *comp_conf = NULL;
    int *pressed_keycode = NULL, *idata = NULL;
    Eina_Bool dup_found = EINA_FALSE;
-   const char* device_name = NULL;
+   const char *device_name = NULL;
+   Ecore_Device_Subclass device_subclas = ECORE_DEVICE_SUBCLASS_NONE;
 
    if (!(edev = libinput_device_get_user_data(device)))
      {
@@ -543,56 +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;
-     }
+        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;
-     }
+        if (!ecore_dev)
+          {
+             ERR("Failed to get source ecore device from event !\n");
+             return;
+          }
 
-   if (edev->e_dev) e_dev = edev->e_dev;
-   else if (edev->e_dev_list && g_list_length(edev->e_dev_list) > 0)
+        device_name = ecore_device_name_get(ecore_dev);
+        device_subclas = ecore_device_subclass_get(ecore_dev);
+     }
+   else
      {
-        glist = edev->e_dev_list;
-        while (glist)
+        if (edev->e_dev) e_dev = edev->e_dev;
+        else if (edev->e_dev_list && g_list_length(edev->e_dev_list) > 0)
           {
-             e_dev_data = glist->data;
-             if (e_device_class_get(e_dev_data) == ECORE_DEVICE_CLASS_KEYBOARD)
+             glist = edev->e_dev_list;
+             while (glist)
                {
-                  e_dev = e_dev_data;
-                  break;
+                  e_dev_data = glist->data;
+                  if (e_device_class_get(e_dev_data) == ECORE_DEVICE_CLASS_KEYBOARD)
+                    {
+                       e_dev = e_dev_data;
+                       break;
+                    }
+
+                  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;
+          }
 
-             glist = g_list_next(glist);
+        if (!e_dev)
+          {
+             ERR("Failed to get source e device from event !\n");
+             return;
           }
-     }
-   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);
@@ -606,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;
           }
@@ -649,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;
           }
      }
@@ -662,13 +670,24 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
         return;
      }
 
-   g_mutex_lock(&edev->xkb.state_mutex);
+   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);
-   g_mutex_unlock(&edev->xkb.state_mutex);
 
    if (nsyms == 1) sym = syms[0];
 
@@ -692,8 +711,6 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
      }
 
    /* if shift is active, we need to transform the key to lower */
-   g_mutex_lock(&edev->xkb.keymap_mutex);
-   g_mutex_lock(&edev->xkb.state_mutex);
    if (xkb_state_mod_index_is_active(edev->xkb.state,
                                      xkb_map_mod_get_index(edev->xkb.keymap,
                                      XKB_MOD_NAME_SHIFT),
@@ -702,8 +719,6 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
         if (keyname[0] != '\0')
           keyname[0] = tolower(keyname[0]);
      }
-   g_mutex_unlock(&edev->xkb.keymap_mutex);
-   g_mutex_unlock(&edev->xkb.state_mutex);
 
    if (_device_keysym_translate(sym, edev->xkb.modifiers,
                                 compose_buffer, sizeof(compose_buffer)))
@@ -758,21 +773,33 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
 
    comp_conf = e_comp_config_get();
 
+   if (comp_conf && comp_conf->input_log_enable)
+     ELOGF("Key", "%s (keyname: %s, keycode: %d, timestamp: %u, device: %s)", NULL, state?"Press":"Release", e->keyname, e->keycode, e->timestamp, device_name);
+
+   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);
-        device_name = e_device_name_get(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
      {
         e->dev = ecore_device_ref(ecore_dev);
-        device_name = ecore_device_name_get(ecore_dev);
         ecore_event_add(state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_input_event_key_cb_free, NULL);
      }
 
-   if (comp_conf && comp_conf->input_log_enable)
-     ELOGF("Key", "%s (keyname: %s, keycode: %d, timestamp: %u, device: %s)", NULL, state?"Press":"Release", e->keyname, e->keycode, e->timestamp, device_name);
+   if (e_config->key_input_ttrace_enable)
+     {
+        TRACE_INPUT_END();
+        ELOGF("INPUT", "ECORE_EVENT_KEY|E|", NULL);
+     }
 
    if (tmp) free(tmp);
 }
@@ -884,17 +911,135 @@ _e_input_pointer_motion_post(E_Input_Evdev *edev)
 }
 
 static void
+_device_pointer_relative_motion(E_Input_Evdev *edev, struct libinput_event_pointer *event, double dx[2], double dy[2])
+{
+   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 (!(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;
+     }
+   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;
+   ev->event_window = (Ecore_Window)input->dev->window;
+   if (event) ev->timestamp = libinput_event_pointer_get_time(event);
+
+   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])
 {
-   uint64_t time_us;
    e_input_relative_motion_cb func = e_input_relative_motion_handler_get();
    if (func)
      {
-        time_us = libinput_event_pointer_get_time_usec(event);
-        func(dx, dy, time_us);
+        //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];
+          }
+
+        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;
+
+        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);
      }
 }
@@ -905,7 +1050,6 @@ _device_handle_pointer_motion(struct libinput_device *device, struct libinput_ev
    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 */
-   double dx, dy, temp;
 
    if (!(edev = libinput_device_get_user_data(device)))
      {
@@ -917,49 +1061,6 @@ _device_handle_pointer_motion(struct libinput_device *device, struct libinput_ev
    delta_y[0] = libinput_event_pointer_get_dy(event);
    delta_y[1] = libinput_event_pointer_get_dy_unaccelerated(event);
 
-   if (edev->disable_acceleration)
-     {
-        dx = delta_x[1];
-        dy = delta_y[1];
-     }
-   else
-     {
-        dx = delta_x[0];
-        dy = delta_y[0];
-     }
-
-   if (edev->seat->ptr.swap)
-     {
-         temp = dx;
-         dx = dy;
-         dy = temp;
-     }
-   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;
-
-   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_send(edev, event, &delta_x[0], &delta_y[0]);
 }
 
@@ -1062,13 +1163,16 @@ _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);
              goto end;
           }
@@ -1082,7 +1186,7 @@ _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);
              goto end;
           }
@@ -1293,12 +1397,15 @@ _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);
+                direction, z, blocked_client, edev->seat->dev->server_blocked);
+
         goto end;
      }
 
@@ -1359,7 +1466,7 @@ _scroll_value_get(struct libinput_event_pointer *pointer_event, enum libinput_po
         value = libinput_event_pointer_get_scroll_value(pointer_event, axis);
         if (comp_conf && comp_conf->input_log_enable)
           {
-             ELOGF("Scroll", "SOURCE_WHEELL value_v120: %lf (cf. value: %lf)", NULL, value_v120, value);
+             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)
           {
@@ -1474,12 +1581,14 @@ _device_handle_axis_v120(struct libinput_device *device, struct libinput_event_p
    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);
+                direction, z, blocked_client, edev->seat->dev->server_blocked);
+
         goto end;
      }
 
@@ -1824,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);
@@ -1892,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;
      }
@@ -2007,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;
@@ -2231,20 +2343,15 @@ 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)
      {
-        g_mutex_lock(&edev->xkb.state_mutex);
         if (edev->xkb.state) xkb_state_unref(edev->xkb.state);
-        g_mutex_unlock(&edev->xkb.state_mutex);
 
-        g_mutex_lock(&edev->xkb.keymap_mutex);
         if (edev->xkb.keymap) xkb_map_unref(edev->xkb.keymap);
-        g_mutex_unlock(&edev->xkb.keymap_mutex);
      }
 
    if (edev->ecore_dev) ecore_device_del(edev->ecore_dev);
@@ -2253,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);
@@ -2349,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));
@@ -2363,32 +2482,34 @@ 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");
 }
 
 EINTERN const char *
@@ -2549,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;
           }
 
@@ -2562,12 +2685,3 @@ e_input_evdev_seatname_set(E_Input_Evdev *evdev, const char *seatname)
 
    return res;
 }
-
-EINTERN Eina_Bool
-e_input_evdev_mouse_accel_enable(E_Input_Evdev *edev, Eina_Bool enable)
-{
-   EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
-   edev->disable_acceleration = !enable;
-
-   return EINA_TRUE;
-}