e_input: do not use E_INPUT_EVENT_INPUT_DEVICE_ADD/DEL events 54/191054/9
authorJengHyun Kang <jhyuni.kang@samsung.com>
Thu, 11 Oct 2018 05:37:32 +0000 (14:37 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Tue, 6 Nov 2018 03:51:00 +0000 (03:51 +0000)
 - use ECORE_EVENT_DEVICE_ADD/DEL events for notify device add/remove

Change-Id: I17d3b742693508c7f472acb50a57c15853e1bc02

src/bin/e_comp_screen.c
src/bin/e_devicemgr.h
src/bin/e_devicemgr_input.c
src/bin/e_input.c
src/bin/e_input.h
src/bin/e_input_evdev.c
src/bin/e_input_inputs.c
src/bin/e_input_private.h

index c6858ce838cfa59d657eec513156550c5d59e087..03e995c46842412ed68ecbc66b8b1c17714f8ad7 100644 (file)
@@ -252,12 +252,12 @@ end:
 static Eina_Bool
 _e_comp_screen_cb_input_device_add(void *data, int type, void *event)
 {
-   E_Input_Event_Input_Device_Add *e;
+   Ecore_Event_Device_Info *e;
    E_Comp *comp = data;
 
    if (!(e = event)) goto end;
 
-   if (e->caps & E_INPUT_SEAT_POINTER)
+   if (e->clas == ECORE_DEVICE_CLASS_MOUSE)
      {
         if (comp->wl_comp_data->ptr.num_devices == 0)
           {
@@ -266,12 +266,12 @@ _e_comp_screen_cb_input_device_add(void *data, int type, void *event)
           }
         comp->wl_comp_data->ptr.num_devices++;
      }
-   if (e->caps & E_INPUT_SEAT_KEYBOARD)
+   else if (e->clas == ECORE_DEVICE_CLASS_KEYBOARD)
      {
         comp->wl_comp_data->kbd.num_devices++;
         e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
      }
-   if (e->caps & E_INPUT_SEAT_TOUCH)
+   else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
      {
         e_comp_wl_input_touch_enabled_set(EINA_TRUE);
         comp->wl_comp_data->touch.num_devices++;
@@ -282,7 +282,7 @@ end:
 }
 
 static void
-_e_comp_screen_pointer_renew(E_Input_Event_Input_Device_Del *ev)
+_e_comp_screen_pointer_renew(void)
 {
      if ((e_comp_wl->ptr.num_devices == 0) && e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->pointer_enter_sent)
      {
@@ -317,12 +317,12 @@ _e_comp_screen_pointer_renew(E_Input_Event_Input_Device_Del *ev)
 static Eina_Bool
 _e_comp_screen_cb_input_device_del(void *data, int type, void *event)
 {
-   E_Input_Event_Input_Device_Del *e;
+   Ecore_Event_Device_Info *e;
    E_Comp *comp = data;
 
    if (!(e = event)) goto end;
 
-   if (e->caps & E_INPUT_SEAT_POINTER)
+   if (e->clas == ECORE_DEVICE_CLASS_MOUSE)
      {
         comp->wl_comp_data->ptr.num_devices--;
         if (comp->wl_comp_data->ptr.num_devices == 0)
@@ -331,10 +331,10 @@ _e_comp_screen_cb_input_device_del(void *data, int type, void *event)
              e_pointer_object_set(comp->pointer, NULL, 0, 0);
              e_pointer_hide(e_comp->pointer);
 
-             _e_comp_screen_pointer_renew(e);
+             _e_comp_screen_pointer_renew();
           }
      }
-   if (e->caps & E_INPUT_SEAT_KEYBOARD)
+   else if (e->clas == ECORE_DEVICE_CLASS_KEYBOARD)
      {
         comp->wl_comp_data->kbd.num_devices--;
         if (comp->wl_comp_data->kbd.num_devices == 0)
@@ -342,7 +342,7 @@ _e_comp_screen_cb_input_device_del(void *data, int type, void *event)
              e_comp_wl_input_keyboard_enabled_set(EINA_FALSE);
           }
      }
-   if (e->caps & E_INPUT_SEAT_TOUCH)
+   else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
      {
         comp->wl_comp_data->touch.num_devices--;
         if (comp->wl_comp_data->touch.num_devices == 0)
@@ -1045,8 +1045,8 @@ e_comp_screen_init()
 
    tzsr_client_hook_del = e_client_hook_add(E_CLIENT_HOOK_DEL, _tz_screen_rotation_cb_client_del, NULL);
 
-   E_LIST_HANDLER_APPEND(event_handlers, E_INPUT_EVENT_INPUT_DEVICE_ADD, _e_comp_screen_cb_input_device_add, comp);
-   E_LIST_HANDLER_APPEND(event_handlers, E_INPUT_EVENT_INPUT_DEVICE_DEL, _e_comp_screen_cb_input_device_del, comp);
+   E_LIST_HANDLER_APPEND(event_handlers, ECORE_EVENT_DEVICE_ADD, _e_comp_screen_cb_input_device_add, comp);
+   E_LIST_HANDLER_APPEND(event_handlers, ECORE_EVENT_DEVICE_DEL, _e_comp_screen_cb_input_device_del, comp);
 
    if (e_comp->e_comp_screen->rotation > 0)
      {
index 00bd6e16aa6f5f819abcfe088062c1774240a60a..d1f68477c895c8506d34d90eca838e145c6278a3 100644 (file)
@@ -101,6 +101,9 @@ E_API Eina_Bool e_devicemgr_is_blocking_event(Ecore_Device_Class clas);
 E_API int e_devicemgr_init(void);
 E_API int e_devicemgr_shutdown(void);
 
+Eina_Bool e_devicemgr_detent_is_detent(const char *name);
+
+
 #endif
 #endif
 
index 2e75c6fd7ce4570eb9171eb89a7dc7cdde61a275..b46f0b3cad9abc471f38bb8fa2af3edbc034b6a1 100644 (file)
@@ -114,8 +114,8 @@ e_devicemgr_keycode_from_string(const char *keyname)
    return keycode;
 }
 
-static Eina_Bool
-_e_devicemgr_detent_is_detent(const char *name)
+Eina_Bool
+e_devicemgr_detent_is_detent(const char *name)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
 
@@ -419,9 +419,6 @@ _e_devicemgr_input_process_mouse_move(Ecore_Event_Mouse_Move *ev)
 {
    Eina_Bool res = ECORE_CALLBACK_PASS_ON;
 
-   if (ev->dev && _e_devicemgr_detent_is_detent(ecore_device_name_get(ev->dev)))
-     return res;
-
    res = e_devicemgr_block_check_move(ev);
 
    return res;
@@ -434,7 +431,7 @@ _e_devicemgr_input_process_mouse_wheel(Ecore_Event_Mouse_Wheel *ev)
 
    if (!ev->dev) return ECORE_CALLBACK_PASS_ON;
 
-   if (!_e_devicemgr_detent_is_detent(ecore_device_name_get(ev->dev)))
+   if (!e_devicemgr_detent_is_detent(ecore_device_name_get(ev->dev)))
      return ECORE_CALLBACK_PASS_ON;
 
    detent = (int)(ev->z / (e_devicemgr->detent.wheel_click_angle
@@ -477,35 +474,7 @@ _e_devicemgr_input_event_filter(void *data EINA_UNUSED, void *loop_data EINA_UNU
 
    if (!event) return res;
 
-   if ((ECORE_EVENT_DEVICE_ADD == type) ||
-       (ECORE_EVENT_DEVICE_DEL == type))
-     {
-        Ecore_Event_Device_Info *ev;
-        ev = (Ecore_Event_Device_Info *)event;
-
-        /* Remove mouse class from tizen detent device */
-        if (_e_devicemgr_detent_is_detent(ev->name))
-          ev->clas &= ~ECORE_DEVICE_CLASS_MOUSE;
-     }
-   else if (E_INPUT_EVENT_INPUT_DEVICE_ADD == type)
-     {
-        E_Input_Event_Input_Device_Add *ev;
-        ev = (E_Input_Event_Input_Device_Add *)event;
-
-        /* Remove pointer capability from tizen detent device */
-        if (_e_devicemgr_detent_is_detent(ev->name))
-          ev->caps &= ~E_INPUT_SEAT_POINTER;
-     }
-   else if (E_INPUT_EVENT_INPUT_DEVICE_DEL == type)
-     {
-        E_Input_Event_Input_Device_Del *ev;
-        ev = (E_Input_Event_Input_Device_Del *)event;
-
-        /* Remove pointer capability from tizen detent device */
-        if (_e_devicemgr_detent_is_detent(ev->name))
-          ev->caps &= ~E_INPUT_SEAT_POINTER;
-     }
-   else if (ECORE_EVENT_KEY_DOWN == type)
+   if (ECORE_EVENT_KEY_DOWN == type)
      {
         Ecore_Event_Key *ev;
         ev = (Ecore_Event_Key *)event;
index 9181043e42bb0ed6d8d03adb24ea4be9b721695b..ac084bda89cde025e9387b88178015688034fb01 100644 (file)
@@ -5,8 +5,6 @@
 int _e_input_init_count;
 int _e_input_log_dom = -1;
 
-E_API int E_INPUT_EVENT_INPUT_DEVICE_ADD = -1;
-E_API int E_INPUT_EVENT_INPUT_DEVICE_DEL = -1;
 E_API int E_INPUT_EVENT_SEAT_ADD = -1;
 E_API int E_EVENT_INPUT_ENABLED = -1;
 E_API int E_EVENT_INPUT_DISABLED = -1;
@@ -68,8 +66,6 @@ e_input_init(Ecore_Evas *ee)
         goto log_err;
      }
 
-   E_INPUT_EVENT_INPUT_DEVICE_ADD = ecore_event_type_new();
-   E_INPUT_EVENT_INPUT_DEVICE_DEL = ecore_event_type_new();
    E_INPUT_EVENT_SEAT_ADD = ecore_event_type_new();
    E_EVENT_INPUT_ENABLED = ecore_event_type_new();
    E_EVENT_INPUT_DISABLED = ecore_event_type_new();
@@ -211,8 +207,6 @@ e_input_shutdown(void)
 
    ecore_event_add(E_EVENT_INPUT_DISABLED, NULL, NULL, NULL);
 
-   E_INPUT_EVENT_INPUT_DEVICE_ADD = -1;
-   E_INPUT_EVENT_INPUT_DEVICE_DEL = -1;
    E_INPUT_EVENT_SEAT_ADD = -1;
    E_EVENT_INPUT_ENABLED = -1;
    E_EVENT_INPUT_DISABLED = -1;
index 4817178d72485d1669387d0cbacafc0a71f4a22d..7d64fb76d5bbcc7bc265f8767c6f3ab0cbcf5be8 100644 (file)
@@ -2,8 +2,6 @@
 
 typedef struct _E_Input E_Input;
 
-E_API extern int E_INPUT_EVENT_INPUT_DEVICE_ADD;
-E_API extern int E_INPUT_EVENT_INPUT_DEVICE_DEL;
 E_API extern int E_INPUT_EVENT_SEAT_ADD;
 E_API extern int E_EVENT_INPUT_ENABLED;
 E_API extern int E_EVENT_INPUT_DISABLED;
@@ -30,38 +28,11 @@ typedef enum _E_Input_Libinput_Backend
    E_INPUT_LIBINPUT_BACKEND_PATH
 } E_Input_Libinput_Backend;
 
-struct _E_Input_Event_Input_Device_Add
-{
-   const char *name; /* descriptive device name */
-   const char *sysname; /* system name of the input device */
-   const char *seatname; /* logical name of the seat */
-   const char *identifier; /* unique identifier (e.g. path) */
-
-   E_Input_Seat_Capabilities caps; /* capabilities on a device */
-   Ecore_Device_Class clas; /* class of a device */
-   Ecore_Device_Subclass subclas; /* subclass of a device */
-};
-
-struct _E_Input_Event_Input_Device_Del
-{
-   const char *name; /* descriptive device name */
-   const char *sysname; /* system name of the input device */
-   const char *seatname; /* logical name of the seat */
-   const char *identifier; /* unique identifier (e.g. path) */
-
-   E_Input_Seat_Capabilities caps; /* capabilities on a device */
-   Ecore_Device_Class clas; /* class of a device */
-   Ecore_Device_Subclass subclas; /* subclass of a device */
-};
-
 typedef struct _E_Input_Device E_Input_Device;
 typedef struct _E_Input_Backend E_Input_Backend;
 typedef struct _E_Input_Evdev E_Input_Evdev;
 typedef struct _E_Input_Seat E_Input_Seat;
 
-typedef struct _E_Input_Event_Input_Device_Add E_Input_Event_Input_Device_Add;
-typedef struct _E_Input_Event_Input_Device_Del E_Input_Event_Input_Device_Del;
-
 struct _E_Input
 {
    Ecore_Window window;
index fa2f94429cb16f9a092a91c3171e69c3340e0407..c981f6706dd89e3efd6f35246edd8bd6bcf44950 100644 (file)
@@ -369,6 +369,8 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
    Ecore_Event_Key *e;
    char *tmp = NULL, *compose = NULL;
    E_Keyrouter_Event_Data *key_data;
+   Ecore_Device *ecore_dev = NULL, *data;
+   Eina_List *l;
 
    if (!(edev = libinput_device_get_user_data(device)))
      {
@@ -380,10 +382,25 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
         return;
      }
 
-   if (!edev->ecore_dev || (ecore_device_class_get(edev->ecore_dev) != ECORE_DEVICE_CLASS_KEYBOARD))
-     edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_KEYBOARD);
+   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_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 (!edev->ecore_dev)
+   if (!ecore_dev)
      {
         ERR("Failed to get source ecore device from event !\n");
         return;
@@ -480,7 +497,7 @@ _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(edev->ecore_dev);
+   e->dev = ecore_device_ref(ecore_dev);
 
    if (state)
      ecore_event_add(ECORE_EVENT_KEY_DOWN, e, _e_input_event_key_cb_free, NULL);
@@ -495,17 +512,47 @@ _device_pointer_motion(E_Input_Evdev *edev, struct libinput_event_pointer *event
 {
    E_Input_Backend *input;
    Ecore_Event_Mouse_Move *ev;
+   Ecore_Device *ecore_dev = NULL, *data, *detent_data = NULL;
+   Eina_List *l;
 
    if (!(input = edev->seat->input)) return;
 
-   if (!edev->ecore_dev || (ecore_device_class_get(edev->ecore_dev) != ECORE_DEVICE_CLASS_MOUSE))
-     edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
+   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 (!edev->ecore_dev)
+   if (!ecore_dev)
      {
         ERR("Failed to get source ecore device from event !\n");
         return;
      }
+   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;
+     }
 
    if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
 
@@ -546,7 +593,7 @@ _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(edev->ecore_dev);
+   ev->dev = ecore_device_ref(ecore_dev);
 
    ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _e_input_event_mouse_move_cb_free, NULL);
 }
@@ -637,6 +684,8 @@ _device_handle_button(struct libinput_device *device, struct libinput_event_poin
    Ecore_Event_Mouse_Button *ev;
    enum libinput_button_state state;
    uint32_t button, timestamp;
+   Ecore_Device *ecore_dev = NULL, *detent_data = NULL, *data;
+   Eina_List *l;
 
    if (!(edev = libinput_device_get_user_data(device)))
      {
@@ -647,10 +696,33 @@ _device_handle_button(struct libinput_device *device, struct libinput_event_poin
         return;
      }
 
-   if (!edev->ecore_dev || (ecore_device_class_get(edev->ecore_dev) != ECORE_DEVICE_CLASS_MOUSE))
-     edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
+   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 (!edev->ecore_dev)
+   if (!ecore_dev)
      {
         ERR("Failed to get source ecore device from event !\n");
         return;
@@ -693,7 +765,7 @@ _device_handle_button(struct libinput_device *device, struct libinput_event_poin
    ev->multi.y = ev->y;
    ev->multi.root.x = ev->x;
    ev->multi.root.y = ev->y;
-   ev->dev = ecore_device_ref(edev->ecore_dev);
+   ev->dev = ecore_device_ref(ecore_dev);
 
    if (state)
      {
@@ -744,6 +816,8 @@ _device_handle_axis(struct libinput_device *device, struct libinput_event_pointe
    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;
 
    if (!(edev = libinput_device_get_user_data(device)))
      {
@@ -754,10 +828,33 @@ _device_handle_axis(struct libinput_device *device, struct libinput_event_pointe
         return;
      }
 
-   if (!edev->ecore_dev || (ecore_device_class_get(edev->ecore_dev) != ECORE_DEVICE_CLASS_MOUSE))
-     edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
+   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 (!edev->ecore_dev)
+   if (!ecore_dev)
      {
         ERR("Failed to get source ecore device from event !\n");
         return;
@@ -783,7 +880,7 @@ _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->dev = ecore_device_ref(edev->ecore_dev);
+   ev->dev = ecore_device_ref(ecore_dev);
 
    axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
    if (libinput_event_pointer_has_axis(event, axis))
@@ -805,14 +902,31 @@ _device_handle_touch_event_send(E_Input_Evdev *edev, struct libinput_event_touch
    E_Input_Backend *input;
    Ecore_Event_Mouse_Button *ev;
    uint32_t timestamp, button = 0;
+   Ecore_Device *ecore_dev = NULL, *data;
+   Eina_List *l;
 
    if (!edev) return;
    if (!(input = edev->seat->input)) return;
 
-   if (!edev->ecore_dev || (ecore_device_class_get(edev->ecore_dev) != ECORE_DEVICE_CLASS_TOUCH))
-     edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
+   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_TOUCH)
+               {
+                  ecore_dev = data;
+                  break;
+               }
+          }
+     }
+   else
+     {
+        edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
+        ecore_dev = edev->ecore_dev;
+     }
 
-   if (!edev->ecore_dev)
+   if (!ecore_dev)
      {
         ERR("Failed to get source ecore device from event !\n");
         return;
@@ -860,7 +974,7 @@ _device_handle_touch_event_send(E_Input_Evdev *edev, struct libinput_event_touch
    ev->multi.y = ev->y;
    ev->multi.root.x = ev->x;
    ev->multi.root.y = ev->y;
-   ev->dev = ecore_device_ref(edev->ecore_dev);
+   ev->dev = ecore_device_ref(ecore_dev);
 
    if (state == ECORE_EVENT_MOUSE_BUTTON_DOWN)
      {
@@ -905,14 +1019,31 @@ _device_handle_touch_motion_send(E_Input_Evdev *edev, struct libinput_event_touc
 {
    E_Input_Backend *input;
    Ecore_Event_Mouse_Move *ev;
+   Ecore_Device *ecore_dev = NULL, *data;
+   Eina_List *l;
 
    if (!edev) return;
    if (!(input = edev->seat->input)) return;
 
-   if (!edev->ecore_dev || (ecore_device_class_get(edev->ecore_dev) != ECORE_DEVICE_CLASS_TOUCH))
-     edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
+   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_TOUCH)
+               {
+                  ecore_dev = data;
+                  break;
+               }
+          }
+     }
+   else
+     {
+        edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
+        ecore_dev = edev->ecore_dev;
+     }
 
-   if (!edev->ecore_dev)
+   if (!ecore_dev)
      {
         ERR("Failed to get source ecore device from event !\n");
         return;
@@ -954,7 +1085,7 @@ _device_handle_touch_motion_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(edev->ecore_dev);
+   ev->dev = ecore_device_ref(ecore_dev);
 
    ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _e_input_event_mouse_move_cb_free, NULL);
 }
@@ -1074,6 +1205,8 @@ _device_handle_touch_aux_data(struct libinput_device *device, struct libinput_ev
    E_Input_Backend *input;
    Ecore_Event_Axis_Update *ev;
    Ecore_Axis *axis;
+   Ecore_Device *ecore_dev = NULL, *data;
+   Eina_List *l;
 
    if (libinput_event_touch_aux_data_get_type(event) != LIBINPUT_TOUCH_AUX_DATA_TYPE_PALM &&
        libinput_event_touch_aux_data_get_value(event) > 0)
@@ -1082,10 +1215,25 @@ _device_handle_touch_aux_data(struct libinput_device *device, struct libinput_ev
    if (!(edev = libinput_device_get_user_data(device))) goto end;
    if (!(input = edev->seat->input)) goto end;
 
-   if (!edev->ecore_dev || (ecore_device_class_get(edev->ecore_dev) != ECORE_DEVICE_CLASS_TOUCH))
-     edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
+   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_TOUCH)
+               {
+                  ecore_dev = data;
+                  break;
+               }
+          }
+     }
+   else
+     {
+        edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
+        ecore_dev = edev->ecore_dev;
+     }
 
-   if (!edev->ecore_dev)
+   if (!ecore_dev)
      {
         ERR("Failed to get source ecore device from event !\n");
         goto end;
@@ -1106,7 +1254,7 @@ _device_handle_touch_aux_data(struct libinput_device *device, struct libinput_ev
         ev->naxis = 1;
      }
    ev->axis = axis;
-   ev->dev = ecore_device_ref(edev->ecore_dev);
+   ev->dev = ecore_device_ref(ecore_dev);
 
    ecore_event_add(ECORE_EVENT_AXIS_UPDATE, ev, _e_input_aux_data_event_free, NULL);
 
@@ -1178,6 +1326,8 @@ _e_input_evdev_device_create(E_Input_Seat *seat, struct libinput_device *device)
 void
 _e_input_evdev_device_destroy(E_Input_Evdev *edev)
 {
+   Ecore_Device *dev;
+
    EINA_SAFETY_ON_NULL_RETURN(edev);
 
    if (edev->caps & E_INPUT_SEAT_KEYBOARD)
@@ -1187,6 +1337,11 @@ _e_input_evdev_device_destroy(E_Input_Evdev *edev)
      }
 
    if (edev->ecore_dev) ecore_device_del(edev->ecore_dev);
+   if (edev->ecore_dev_list)
+     EINA_LIST_FREE(edev->ecore_dev_list, dev)
+       {
+          ecore_device_del(dev);
+       }
    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);
index 3c92894d9a87dc002d0db01e4a7207c26eeb06e9..9739e30cba5dab73b508468bad06ae8cec5a135c 100644 (file)
@@ -1,6 +1,40 @@
 #include "e.h"
 #include "e_input_private.h"
 
+static char *
+_e_input_ecore_device_class_to_string(Ecore_Device_Class clas)
+{
+   switch (clas)
+     {
+        case ECORE_DEVICE_CLASS_NONE:
+          return "None";
+          break;
+        case ECORE_DEVICE_CLASS_SEAT:
+          return "Seat";
+          break;
+        case ECORE_DEVICE_CLASS_KEYBOARD:
+          return "Keyboard";
+          break;
+        case ECORE_DEVICE_CLASS_MOUSE:
+          return "Mouse";
+          break;
+        case ECORE_DEVICE_CLASS_TOUCH:
+          return "Touch";
+          break;
+        case ECORE_DEVICE_CLASS_PEN:
+          return "Pen";
+          break;
+        case ECORE_DEVICE_CLASS_WAND:
+          return "Wand";
+          break;
+        case ECORE_DEVICE_CLASS_GAMEPAD:
+          return "Gamepad";
+          break;
+        default:
+          return "Unknown";
+     }
+}
+
 static Ecore_Device_Class
 _e_input_seat_cap_to_ecore_device_class(unsigned int cap)
 {
@@ -94,34 +128,6 @@ _seat_create(E_Input_Backend *input, const char *seat)
    return s;
 }
 
-static void
-_e_input_event_input_device_add_free(void *data EINA_UNUSED, void *ev)
-{
-   E_Input_Event_Input_Device_Add *e;
-
-   e = ev;
-   eina_stringshare_del(e->name);
-   eina_stringshare_del(e->sysname);
-   eina_stringshare_del(e->seatname);
-   eina_stringshare_del(e->identifier);
-
-   free(e);
-}
-
-static void
-_e_input_event_input_device_del_free(void *data EINA_UNUSED, void *ev)
-{
-   E_Input_Event_Input_Device_Del *e;
-
-   e = ev;
-   eina_stringshare_del(e->name);
-   eina_stringshare_del(e->sysname);
-   eina_stringshare_del(e->seatname);
-   eina_stringshare_del(e->identifier);
-
-   free(e);
-}
-
 static E_Input_Seat *
 _seat_get(E_Input_Backend *input, const char *seat)
 {
@@ -136,7 +142,6 @@ _seat_get(E_Input_Backend *input, const char *seat)
    return _seat_create(input, seat);
 }
 
-
 static Eina_Bool
 _e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
 {
@@ -172,7 +177,27 @@ _e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
    ecore_device_class_set(dev, clas);
    ecore_device_subclass_set(dev, ECORE_DEVICE_SUBCLASS_NONE);
 
-   edev->ecore_dev = ecore_device_ref(dev);
+   if (!edev->ecore_dev)
+     {
+        if (!edev->ecore_dev_list || (eina_list_count(edev->ecore_dev_list) == 0))
+          {
+             /* 1st Ecore_Device is added */
+             edev->ecore_dev = ecore_device_ref(dev);
+          }
+        else
+          {
+             /* 3rd or more Ecore_Device is added */
+             edev->ecore_dev_list = eina_list_append(edev->ecore_dev_list, ecore_device_ref(dev));
+          }
+     }
+   else
+     {
+        /* 2nd Ecore_Device is added */
+        edev->ecore_dev_list = eina_list_append(edev->ecore_dev_list, edev->ecore_dev);
+        edev->ecore_dev = NULL;
+
+        edev->ecore_dev_list = eina_list_append(edev->ecore_dev_list, ecore_device_ref(dev));
+     }
 
    _e_input_ecore_device_event(dev, EINA_TRUE);
 
@@ -182,9 +207,9 @@ _e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
 static Eina_Bool
 _e_input_remove_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
 {
-   const Eina_List *dev_list = NULL;
-   const Eina_List *l;
-   Ecore_Device *dev = NULL;
+   const Eina_List *dev_list = NULL, *l;
+   Eina_List *ll, *ll_next;
+   Ecore_Device *dev = NULL, *data;
    const char *identifier;
 
    if (!edev->path) return EINA_FALSE;
@@ -198,8 +223,18 @@ _e_input_remove_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
          if (!identifier) continue;
          if ((ecore_device_class_get(dev) == clas) && (!strcmp(identifier, edev->path)))
            {
+              if (edev->ecore_dev) edev->ecore_dev = NULL;
+              else if (edev->ecore_dev_list)
+                {
+                   EINA_LIST_FOREACH_SAFE(edev->ecore_dev_list, ll, ll_next, data)
+                     {
+                        if (data == dev)
+                          {
+                             edev->ecore_dev_list = eina_list_remove_list(edev->ecore_dev_list, ll);
+                          }
+                     }
+                }
               ecore_device_del(dev);
-              edev->ecore_dev = NULL;
               _e_input_ecore_device_event(dev, EINA_FALSE);
               return EINA_TRUE;
            }
@@ -211,11 +246,12 @@ Eina_Bool
 _e_input_device_add(E_Input_Evdev *edev)
 {
    Eina_Bool ret = EINA_FALSE;
-   Ecore_Device_Class clas;
+   Ecore_Device_Class clas = ECORE_DEVICE_CLASS_NONE;
 
    if (edev->caps & E_INPUT_SEAT_POINTER)
      {
-        clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_POINTER);
+        if (!e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
+          clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_POINTER);
         ret = _e_input_add_ecore_device(edev, clas);
      }
    if (edev->caps & E_INPUT_SEAT_KEYBOARD)
@@ -235,11 +271,13 @@ _e_input_device_add(E_Input_Evdev *edev)
 void
 _e_input_device_remove(E_Input_Evdev *edev)
 {
-   Ecore_Device_Class clas;
+   Ecore_Device_Class clas = ECORE_DEVICE_CLASS_NONE;
+   Ecore_Device *data;
 
    if (edev->caps & E_INPUT_SEAT_POINTER)
      {
-        clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_POINTER);
+        if (!e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
+          clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_POINTER);
         _e_input_remove_ecore_device(edev, clas);
      }
    if (edev->caps & E_INPUT_SEAT_KEYBOARD)
@@ -252,6 +290,21 @@ _e_input_device_remove(E_Input_Evdev *edev)
         clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_TOUCH);
         _e_input_remove_ecore_device(edev, clas);
      }
+
+   if (edev->ecore_dev_list)
+     {
+        if (eina_list_count(edev->ecore_dev_list) > 0)
+          {
+             EINA_LIST_FREE(edev->ecore_dev_list, data)
+               {
+                  WRN("Invalid device is left. name: %s, identifier: %s, clas: %s\n",
+                      ecore_device_name_get(data), ecore_device_description_get(data),
+                      _e_input_ecore_device_class_to_string(ecore_device_class_get(data)));
+                  ecore_device_del(data);
+               }
+          }
+        edev->ecore_dev_list = NULL;
+     }
 }
 
 static void
@@ -261,7 +314,6 @@ _device_added(E_Input_Backend *input, struct libinput_device *device)
    const char *seat_name;
    E_Input_Seat *seat;
    E_Input_Evdev *edev;
-   E_Input_Event_Input_Device_Add *ev;
 
    libinput_seat = libinput_device_get_seat(device);
    seat_name = libinput_seat_get_logical_name(libinput_seat);
@@ -285,38 +337,17 @@ _device_added(E_Input_Backend *input, struct libinput_device *device)
    /* append this device to the seat */
    seat->devices = eina_list_append(seat->devices, edev);
 
-   ev = calloc(1, sizeof(E_Input_Event_Input_Device_Add));
-   if (!ev)
-     {
-        return;
-     }
-
    if (EINA_FALSE == _e_input_device_add(edev))
      {
         ERR("Failed to create evas device !\n");
-               free(ev);
         return;
      }
-
-   ev->name = eina_stringshare_add(libinput_device_get_name(device));
-   ev->sysname = eina_stringshare_add(edev->path);
-   ev->seatname = eina_stringshare_add(edev->seat->name);
-   ev->caps = edev->caps;
-   ev->clas = ecore_device_class_get(edev->ecore_dev);
-   ev->identifier = eina_stringshare_add(edev->path);
-   ev->subclas = ecore_device_subclass_get(edev->ecore_dev);
-
-   ecore_event_add(E_INPUT_EVENT_INPUT_DEVICE_ADD,
-                   ev,
-                   _e_input_event_input_device_add_free,
-                   NULL);
 }
 
 static void
 _device_removed(E_Input_Backend *input, struct libinput_device *device)
 {
    E_Input_Evdev *edev;
-   E_Input_Event_Input_Device_Del *ev;
 
    /* try to get the evdev structure */
    if (!(edev = libinput_device_get_user_data(device)))
@@ -324,25 +355,6 @@ _device_removed(E_Input_Backend *input, struct libinput_device *device)
         return;
      }
 
-   ev = calloc(1, sizeof(E_Input_Event_Input_Device_Del));
-   if (!ev)
-     {
-        return;
-     }
-
-   ev->name = eina_stringshare_add(libinput_device_get_name(device));
-   ev->sysname = eina_stringshare_add(edev->path);
-   ev->seatname = eina_stringshare_add(edev->seat->name);
-   ev->caps = edev->caps;
-   ev->clas = ecore_device_class_get(edev->ecore_dev);
-   ev->identifier = eina_stringshare_add(edev->path);
-   ev->subclas = ecore_device_subclass_get(edev->ecore_dev);
-
-   ecore_event_add(E_INPUT_EVENT_INPUT_DEVICE_DEL,
-                   ev,
-                   _e_input_event_input_device_del_free,
-                   NULL);
-
    _e_input_device_remove(edev);
 
    /* remove this evdev from the seat's list of devices */
index 3fc4da67957ce357fc888527b4314083c2d3a307..3eb48f8cb76d1fcbcde741d4a558d798b54753ca 100644 (file)
@@ -65,6 +65,7 @@ struct _E_Input_Evdev
    const char *path;
    int fd;
    Ecore_Device *ecore_dev;
+   Eina_List *ecore_dev_list;
 
    int mt_slot;