ecore: support a Ecore_Device 73/167573/11
authorJengHyun Kang <jhyuni.kang@samsung.com>
Tue, 16 Jan 2018 04:12:57 +0000 (13:12 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Tue, 23 Jan 2018 05:32:34 +0000 (05:32 +0000)
Change-Id: I63ad58b537f804867acb77f9a530b7e02005dce2

15 files changed:
src/Makefile_Efl.am
src/lib/ecore/Ecore_Common.h
src/lib/ecore/ecore_device.c
src/lib/ecore_input/ecore_input.c
src/lib/ecore_input_evas/ecore_input_evas.c
src/lib/ecore_wl2/ecore_wl2_input.c
src/lib/ecore_wl2/ecore_wl2_private.h
src/lib/efl/CMakeLists.txt
src/lib/efl/Efl.h
src/lib/efl/interfaces/efl_common_internal.h
src/lib/efl/interfaces/efl_ecore_input_device.c [new file with mode: 0644]
src/lib/efl/interfaces/efl_ecore_input_device.eo [new file with mode: 0644]
src/lib/evas/Evas_Common.h
src/lib/evas/canvas/evas_device.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c

index c91a250..b4fa663 100644 (file)
@@ -6,6 +6,7 @@ efl_eolian_legacy_files = \
        lib/efl/interfaces/efl_image.eo \
        lib/efl/interfaces/efl_image_animated.eo \
        lib/efl/interfaces/efl_input_device.eo \
+       lib/efl/interfaces/efl_ecore_input_device.eo \
         lib/efl/interfaces/efl_ui_draggable.eo \
         lib/efl/interfaces/efl_ui_clickable.eo \
         lib/efl/interfaces/efl_ui_scrollable.eo \
@@ -130,6 +131,7 @@ lib/efl/interfaces/efl_vpath_manager.c \
 lib/efl/interfaces/efl_vpath_core.c \
 lib/efl/interfaces/efl_vpath_file_core.c \
 lib/efl/interfaces/efl_input_device.c \
+lib/efl/interfaces/efl_ecore_input_device.c \
 lib/efl/interfaces/efl_io_closer.c \
 lib/efl/interfaces/efl_io_positioner.c \
 lib/efl/interfaces/efl_io_reader.c \
index 1298ba0..e19f313 100644 (file)
@@ -3230,37 +3230,38 @@ typedef Eo                 Ecore_Device; /**< A handle for an device */
   * @typedef Ecore_Device_Class
   * An enum of Device Classes.
   */
-typedef enum _Ecore_Device_Class
-  {
-     ECORE_DEVICE_CLASS_NONE, /**< Not a device @since 1.18 */
-     ECORE_DEVICE_CLASS_SEAT, /**< The user/seat (the user themselves) @since 1.18 */
-     ECORE_DEVICE_CLASS_KEYBOARD, /**< A regular keyboard, numberpad or attached buttons @since 1.18 */
-     ECORE_DEVICE_CLASS_MOUSE, /**< A mouse, trackball or touchpad relative motion device @since 1.18 */
-     ECORE_DEVICE_CLASS_TOUCH, /**< A touchscreen with fingers or stylus @since 1.18 */
-     ECORE_DEVICE_CLASS_PEN, /**< A special pen device @since 1.18 */
-     ECORE_DEVICE_CLASS_POINTER, /**< A laser pointer, wii-style or 7"minority report" pointing device @since 1.18 */
-     ECORE_DEVICE_CLASS_GAMEPAD /**<  A gamepad controller or joystick @since 1.18 */
-  } Ecore_Device_Class; /**< A general class of device @since 1.18 */
+typedef Efl_Ecore_Input_Device_Type Ecore_Device_Class;
+
+#define ECORE_DEVICE_CLASS_NONE             EFL_ECORE_INPUT_DEVICE_TYPE_NONE /**< Not a device @since 1.8 */
+#define ECORE_DEVICE_CLASS_SEAT             EFL_ECORE_INPUT_DEVICE_TYPE_SEAT /**< The user/seat (the user themselves) @since 1.8 */
+#define ECORE_DEVICE_CLASS_KEYBOARD         EFL_ECORE_INPUT_DEVICE_TYPE_KEYBOARD /**< A regular keyboard, numberpad or attached buttons @since 1.8 */
+#define ECORE_DEVICE_CLASS_MOUSE            EFL_ECORE_INPUT_DEVICE_TYPE_MOUSE /**< A mouse, trackball or touchpad relative motion device @since 1.8 */
+#define ECORE_DEVICE_CLASS_TOUCH            EFL_ECORE_INPUT_DEVICE_TYPE_TOUCH /**< A touchscreen with fingers or stylus @since 1.8 */
+#define ECORE_DEVICE_CLASS_PEN              EFL_ECORE_INPUT_DEVICE_TYPE_PEN /**< A special pen device @since 1.8 */
+#define ECORE_DEVICE_CLASS_POINTER          EFL_ECORE_INPUT_DEVICE_TYPE_WAND /**< A laser pointer, wii-style or "minority report" pointing device @since 1.8 */
+#define ECORE_DEVICE_CLASS_WAND             EFL_ECORE_INPUT_DEVICE_TYPE_WAND /**< A synonym for ECORE_DEVICE_CLASS_POINTER @since 1.18 */
+#define ECORE_DEVICE_CLASS_GAMEPAD          EFL_ECORE_INPUT_DEVICE_TYPE_GAMEPAD /**<  A gamepad controller or joystick @since 1.8 */
+
+
  /**
    * @typedef Ecore_Device_Subclass
    * An enum of Device Subclasses.
    */
-typedef enum _Ecore_Device_Subclass
-  {
-     ECORE_DEVICE_SUBCLASS_NONE, /**< Not a device @since 1.18 */
-     ECORE_DEVICE_SUBCLASS_FINGER, /**< The normal flat of your finger @since 1.18 */
-     ECORE_DEVICE_SUBCLASS_FINGERNAIL, /**< A fingernail @since 1.18 */
-     ECORE_DEVICE_SUBCLASS_KNUCKLE, /**< A Knuckle @since 1.18 */
-     ECORE_DEVICE_SUBCLASS_PALM, /**< The palm of a users hand @since 1.18 */
-     ECORE_DEVICE_SUBCLASS_HAND_SIZE, /**< The side of your hand @since 1.18 */
-     ECORE_DEVICE_SUBCLASS_HAND_FLAT, /**< The flat of your hand @since 1.18 */
-     ECORE_DEVICE_SUBCLASS_PEN_TIP, /**< The tip of a pen @since 1.18 */
-     ECORE_DEVICE_SUBCLASS_TRACKPAD, /**< A trackpad style mouse @since 1.18 */
-     ECORE_DEVICE_SUBCLASS_TRACKPOINT, /**< A trackpoint style mouse @since 1.18 */
-     ECORE_DEVICE_SUBCLASS_TRACKBALL, /**< A trackball style mouse @since 1.18 */
-     ECORE_DEVICE_SUBCLASS_REMOCON, /**< A remote controller @since_tizen 4.0 */
-     ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD /**< A virtual keyboard @since_tizen 4.0*/
-  } Ecore_Device_Subclass; /**< A general subclass of device @since 1.18 */
+typedef Efl_Ecore_Input_Device_Subtype Ecore_Device_Subclass;
+
+#define ECORE_DEVICE_SUBCLASS_NONE   EFL_ECORE_INPUT_DEVICE_SUBTYPE_NONE /**< Not a device @since 1.18 */
+#define ECORE_DEVICE_SUBCLASS_FINGER   EFL_ECORE_INPUT_DEVICE_SUBTYPE_FINGER /**< The normal flat of your finger @since 1.18 */
+#define ECORE_DEVICE_SUBCLASS_FINGERNAIL   EFL_ECORE_INPUT_DEVICE_SUBTYPE_FINGERNAIL /**< A fingernail @since 1.18 */
+#define ECORE_DEVICE_SUBCLASS_KNUCKLE   EFL_ECORE_INPUT_DEVICE_SUBTYPE_KNUCKLE /**< A Knuckle @since 1.18 */
+#define ECORE_DEVICE_SUBCLASS_PALM   EFL_ECORE_INPUT_DEVICE_SUBTYPE_PALM /**< The palm of a users hand @since 1.18 */
+#define ECORE_DEVICE_SUBCLASS_HAND_SIZE   EFL_ECORE_INPUT_DEVICE_SUBTYPE_HAND_SIZE /**< The side of your hand @since 1.18 */
+#define ECORE_DEVICE_SUBCLASS_HAND_FLAT   EFL_ECORE_INPUT_DEVICE_SUBTYPE_HAND_FLAT /**< The flat of your hand @since 1.18 */
+#define ECORE_DEVICE_SUBCLASS_PEN_TIP   EFL_ECORE_INPUT_DEVICE_SUBTYPE_PEN_TIP /**< The tip of a pen @since 1.18 */
+#define ECORE_DEVICE_SUBCLASS_TRACKPAD   EFL_ECORE_INPUT_DEVICE_SUBTYPE_TRACKPAD /**< A trackpad style mouse @since 1.18 */
+#define ECORE_DEVICE_SUBCLASS_TRACKPOINT   EFL_ECORE_INPUT_DEVICE_SUBTYPE_TRACKPOINT /**< A trackpoint style mouse @since 1.18 */
+#define ECORE_DEVICE_SUBCLASS_TRACKBALL   EFL_ECORE_INPUT_DEVICE_SUBTYPE_TRACKBALL /**< A trackball style mouse @since 1.18 */
+#define ECORE_DEVICE_SUBCLASS_REMOCON   EFL_ECORE_INPUT_DEVICE_SUBTYPE_REMOCON /**< A remote controller @since_tizen 4.0 */
+#define ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD   EFL_ECORE_INPUT_DEVICE_SUBTYPE_VIRTUAL_KEYBOARD /**< A virtual keyboard @since_tizen 4.0*/
 
 typedef struct _Ecore_Device_Event_Info Ecore_Device_Event_Info; /**< @since 1.18 */
 
index 519db10..ec0eff4 100644 (file)
@@ -8,6 +8,25 @@
 #include "Ecore.h"
 #include "ecore_private.h"
 
+#define EFL_INTERNAL_UNSTABLE
+#include "interfaces/efl_common_internal.h"
+
+/* WARNING: This API is not used across EFL, hard to test! */
+
+#ifdef DEBUG_UNTESTED_
+// booh
+#define SAFETY_CHECK(obj, klass, ...) \
+   do { MAGIC_CHECK(dev, Ecore_Device, 1); \
+        return __VA_ARGS__; \
+        MAGIC_CHECK_END(); \
+   } while (0)
+
+#else
+#define SAFETY_CHECK(obj, klass, ...) \
+   do { if (!obj) return __VA_ARGS__; } while (0)
+#endif
+
+#if 0
 /**
  * @struct _Ecore_Device
  * Contains information about a device.
@@ -21,95 +40,141 @@ struct _Ecore_Device
      Ecore_Device_Class clas; /**<Device class */
      Ecore_Device_Subclass subclas; /**< device subclass */
   };
+#endif
+static Eina_List *_ecore_devices = NULL;
+static int devices_num;
 
 EAPI Ecore_Device *
 ecore_device_add()
 {
-   WRN("ecore_device is deprecated in efl. Please use efl_device APIs instead\n");
-   return NULL;
+   Ecore_Device *dev;
+   Efl_Ecore_Input_Device_Data *d;
+
+   dev = efl_add(EFL_ECORE_INPUT_DEVICE_CLASS, NULL,
+                 efl_name_set(efl_added, NULL),
+                 efl_comment_set(efl_added, NULL),
+                 efl_ecore_input_device_type_set(efl_added, EFL_ECORE_INPUT_DEVICE_TYPE_NONE),
+                 efl_ecore_input_device_source_set(efl_added, NULL));
+
+   d = efl_data_scope_get(dev, EFL_ECORE_INPUT_DEVICE_CLASS);
+   d->subclass = EFL_ECORE_INPUT_DEVICE_SUBTYPE_NONE;
+
+   _ecore_devices = eina_list_append(_ecore_devices, dev);
+   devices_num++;
+
+   return dev;
 }
 
 EAPI void
-ecore_device_del(Ecore_Device *dev EINA_UNUSED)
+ecore_device_del(Ecore_Device *dev)
 {
-   WRN("ecore_device is deprecated in efl. Please use efl_device APIs instead\n");
+   Eina_List *l, *l_next;
+   Ecore_Device *data;
+
+   SAFETY_CHECK(dev, EFL_ECORE_INPUT_DEVICE_CLASS);
+
+   EINA_LIST_FOREACH_SAFE(_ecore_devices, l, l_next, data)
+     {
+        if (dev == data)
+          _ecore_devices = eina_list_remove_list(_ecore_devices, l);
+     }
+   devices_num--;
+
+   efl_del(dev);
    return;
 }
 
 EAPI const Eina_List *
 ecore_device_list(void)
 {
-   WRN("ecore_device is deprecated in efl. Please use efl_device APIs instead\n");
-   return NULL;
+   return _ecore_devices;
 }
 
 EAPI void
-ecore_device_name_set(Ecore_Device *dev EINA_UNUSED, const char *name EINA_UNUSED)
+ecore_device_name_set(Ecore_Device *dev, const char *name)
 {
-   WRN("ecore_device is deprecated in efl. Please use efl_device APIs instead\n");
-   return;
+   SAFETY_CHECK(dev, EFL_ECORE_INPUT_DEVICE_CLASS);
+
+   efl_name_set(dev, name);
 }
 
 EAPI const char *
-ecore_device_name_get(const Ecore_Device *dev EINA_UNUSED)
+ecore_device_name_get(const Ecore_Device *dev)
 {
-   WRN("ecore_device is deprecated in efl. Please use efl_device APIs instead\n");
-   return NULL;
+   SAFETY_CHECK(dev, EFL_ECORE_INPUT_DEVICE_CLASS, NULL);
+
+   return efl_name_get(dev);
 }
 
 EAPI void
-ecore_device_description_set(Ecore_Device *dev EINA_UNUSED, const char *desc EINA_UNUSED)
+ecore_device_description_set(Ecore_Device *dev, const char *desc)
 {
-   WRN("ecore_device is deprecated in efl. Please use efl_device APIs instead\n");
-   return;
+   SAFETY_CHECK(dev, EFL_ECORE_INPUT_DEVICE_CLASS);
+
+   efl_comment_set(dev, desc);
 }
 
 EAPI const char *
-ecore_device_description_get(const Ecore_Device *dev EINA_UNUSED)
+ecore_device_description_get(const Ecore_Device *dev)
 {
-   WRN("ecore_device is deprecated in efl. Please use efl_device APIs instead\n");
-   return NULL;
+   SAFETY_CHECK(dev, EFL_ECORE_INPUT_DEVICE_CLASS, NULL);
+
+   return efl_comment_get(dev);
 }
 
 EAPI void
-ecore_device_identifier_set(Ecore_Device *dev EINA_UNUSED, const char *identifier EINA_UNUSED)
+ecore_device_identifier_set(Ecore_Device *dev, const char *identifier)
 {
-   WRN("ecore_device is deprecated in efl. Please use efl_device APIs instead\n");
-   return;
+   SAFETY_CHECK(dev, EFL_ECORE_INPUT_DEVICE_CLASS);
+
+   efl_comment_set(dev, identifier);
 }
 
 EAPI const char *
-ecore_device_identifier_get(const Ecore_Device *dev EINA_UNUSED)
+ecore_device_identifier_get(const Ecore_Device *dev)
 {
-   WRN("ecore_device is deprecated in efl. Please use efl_device APIs instead\n");
-   return NULL;
+   SAFETY_CHECK(dev, EFL_ECORE_INPUT_DEVICE_CLASS, NULL);
+
+   return efl_comment_get(dev);
 }
 
 EAPI void
-ecore_device_class_set(Ecore_Device *dev EINA_UNUSED, Ecore_Device_Class clas EINA_UNUSED)
+ecore_device_class_set(Ecore_Device *dev, Ecore_Device_Class clas)
 {
-   WRN("ecore_device is deprecated in efl. Please use efl_device APIs instead\n");
-   return;
+   SAFETY_CHECK(dev, EFL_ECORE_INPUT_DEVICE_CLASS);
+
+   efl_ecore_input_device_type_set(dev, clas);
 }
 
 EAPI Ecore_Device_Class
-ecore_device_class_get(const Ecore_Device *dev EINA_UNUSED)
+ecore_device_class_get(const Ecore_Device *dev)
 {
-   WRN("ecore_device is deprecated in efl. Please use efl_device APIs instead\n");
-   return 0;
+   SAFETY_CHECK(dev, EFL_ECORE_INPUT_DEVICE_CLASS, EFL_ECORE_INPUT_DEVICE_TYPE_NONE);
+
+   return efl_ecore_input_device_type_get(dev);
 }
 
 EAPI void
-ecore_device_subclass_set(Ecore_Device *dev EINA_UNUSED, Ecore_Device_Subclass subclas EINA_UNUSED)
+ecore_device_subclass_set(Ecore_Device *dev, Ecore_Device_Subclass subclas)
 {
-   WRN("ecore_device is deprecated in efl. Please use efl_device APIs instead\n");
-   return;
+   Efl_Ecore_Input_Device_Data *d;
+   SAFETY_CHECK(dev, EFL_ECORE_INPUT_DEVICE_CLASS);
+
+   d = efl_data_scope_get(dev, EFL_ECORE_INPUT_DEVICE_CLASS);
+   if (!d) return;
+
+   d->subclass = subclas;
 }
 
 EAPI Ecore_Device_Subclass
-ecore_device_subclass_get(const Ecore_Device *dev EINA_UNUSED)
+ecore_device_subclass_get(const Ecore_Device *dev)
 {
-   WRN("ecore_device is deprecated in efl. Please use efl_device APIs instead\n");
-   return 0;
+   Efl_Ecore_Input_Device_Data *d;
+   SAFETY_CHECK(dev, EFL_ECORE_INPUT_DEVICE_CLASS, EFL_ECORE_INPUT_DEVICE_SUBTYPE_NONE);
+
+   d = efl_data_scope_get(dev, EFL_ECORE_INPUT_DEVICE_CLASS);
+   if (!d) return 0;
+
+   return d->subclass;
 }
 //
index 73b03e9..d581760 100644 (file)
@@ -68,6 +68,10 @@ ecore_event_init(void)
    // TIZEN_ONLY(20171109): support a tizen_input_device_manager interface
    ECORE_EVENT_DETENT_ROTATE = ecore_event_type_new();
    //
+   // TIZEN_ONLY(20180118): support a Ecore_Device
+   ECORE_EVENT_DEVICE_ADD = ecore_event_type_new();
+   ECORE_EVENT_DEVICE_DEL = ecore_event_type_new();
+   //
 
    //TIZEN_ONLY(20170307) Remove warning message
    #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@@ -97,7 +101,11 @@ ecore_event_shutdown(void)
                           ECORE_EVENT_MOUSE_BUTTON_CANCEL,
                           ECORE_EVENT_JOYSTICK,
                           // TIZEN_ONLY(20171109): support a tizen_input_device_manager interface
-                          ECORE_EVENT_DETENT_ROTATE
+                          ECORE_EVENT_DETENT_ROTATE,
+                          //
+                          // TIZEN_ONLY(20180118): support a Ecore_Device
+                          ECORE_EVENT_DEVICE_ADD,
+                          ECORE_EVENT_DEVICE_DEL
                           //
                           );
    //TIZEN_ONLY(20170307) Remove warning message
index 7c83072..3f8d70c 100644 (file)
@@ -452,6 +452,107 @@ _ecore_event_window_match(Ecore_Window id)
    return lookup;
 }
 
+// TIZEN_ONLY(20180118): support a Ecore_Device
+Evas_Device *
+_ecore_event_evas_device_find(Evas *eo_e, Ecore_Device *ecore_dev)
+{
+   Eina_List *list, *l;
+   Evas_Device *evas_device;
+
+   list = (Eina_List *)evas_device_list(eo_e, NULL);
+   EINA_LIST_FOREACH(list, l, evas_device)
+     {
+        if ((evas_device_class_get(evas_device) == (Evas_Device_Class)ecore_device_class_get(ecore_dev)) &&
+            !strncmp(efl_name_get(evas_device), efl_name_get(ecore_dev), strlen(efl_name_get(evas_device))) &&
+            !strncmp(efl_comment_get(evas_device), efl_comment_get(ecore_dev), strlen(efl_comment_get(evas_device))))
+          {
+             return evas_device;
+          }
+     }
+   return NULL;
+}
+
+static void
+_ecore_event_device_check(Evas *eo_e, int type, void *ev, Eo *dev)
+{
+   Evas_Device *evas_device;
+   Eo *tmp_dev;
+
+   if (efl_class_get(dev) != EFL_ECORE_INPUT_DEVICE_CLASS) return;
+
+   evas_device = _ecore_event_evas_device_find(eo_e, dev);
+   if (!evas_device)
+     {
+        WRN("Failed to found evas device for %s (identifier: %s, class: %d)\n", efl_name_get(dev), efl_comment_get(dev), efl_ecore_input_device_type_get(dev));
+        if (type == ECORE_EVENT_KEY_DOWN || type == ECORE_EVENT_KEY_UP)
+          evas_device = evas_device_default_get(eo_e, EVAS_DEVICE_CLASS_KEYBOARD);
+        else
+          {
+             if (ecore_device_class_get(dev) == ECORE_DEVICE_CLASS_TOUCH)
+               evas_device = evas_device_default_get(eo_e, EVAS_DEVICE_CLASS_TOUCH);
+             else
+               evas_device = evas_device_default_get(eo_e, EVAS_DEVICE_CLASS_MOUSE);
+          }
+     }
+
+   if (evas_device)
+     {
+        if (type == ECORE_EVENT_KEY_DOWN ||
+            type == ECORE_EVENT_KEY_UP)
+          {
+             Ecore_Event_Key *e = (Ecore_Event_Key *)ev;
+
+             tmp_dev = e->dev;
+             e->dev = efl_ref(evas_device);
+             efl_unref(tmp_dev);
+          }
+        else if (type == ECORE_EVENT_MOUSE_BUTTON_DOWN ||
+                 type == ECORE_EVENT_MOUSE_BUTTON_UP ||
+                 type == ECORE_EVENT_MOUSE_BUTTON_CANCEL)
+          {
+             Ecore_Event_Mouse_Button *e = (Ecore_Event_Mouse_Button *)ev;
+
+             tmp_dev = e->dev;
+             e->dev = efl_ref(evas_device);
+             efl_unref(tmp_dev);
+          }
+        else if (type == ECORE_EVENT_MOUSE_MOVE)
+          {
+             Ecore_Event_Mouse_Move *e = (Ecore_Event_Mouse_Move *)ev;
+
+             tmp_dev = e->dev;
+             e->dev = efl_ref(evas_device);
+             efl_unref(tmp_dev);
+          }
+        else if (type == ECORE_EVENT_MOUSE_IN ||
+                 type == ECORE_EVENT_MOUSE_OUT)
+          {
+             Ecore_Event_Mouse_IO *e = (Ecore_Event_Mouse_IO *)ev;
+
+             tmp_dev = e->dev;
+             e->dev = efl_ref(evas_device);
+             efl_unref(tmp_dev);
+          }
+        else if (type == ECORE_EVENT_MOUSE_WHEEL)
+          {
+             Ecore_Event_Mouse_Wheel *e = (Ecore_Event_Mouse_Wheel *)ev;
+
+             tmp_dev = e->dev;
+             e->dev = efl_ref(evas_device);
+             efl_unref(tmp_dev);
+          }
+        else if (type == ECORE_EVENT_AXIS_UPDATE)
+          {
+             Ecore_Event_Axis_Update *e = (Ecore_Event_Axis_Update *)ev;
+
+             tmp_dev = e->dev;
+             e->dev = efl_ref(evas_device);
+             efl_unref(tmp_dev);
+          }
+     }
+}
+//
+
 static Eina_Bool
 _ecore_event_evas_key(Ecore_Event_Key *e, Ecore_Event_Press press)
 {
@@ -461,6 +562,12 @@ _ecore_event_evas_key(Ecore_Event_Key *e, Ecore_Event_Press press)
 
    lookup = _ecore_event_window_match(e->event_window);
    if (!lookup) return ECORE_CALLBACK_PASS_ON;
+   // TIZEN_ONLY(20180118): support a Ecore_Device
+   if (press == ECORE_DOWN)
+     _ecore_event_device_check(lookup->evas, ECORE_EVENT_KEY_DOWN, e, e->dev);
+   else
+     _ecore_event_device_check(lookup->evas, ECORE_EVENT_KEY_UP, e, e->dev);
+   //
    seat = e->dev ? efl_input_device_seat_get(e->dev) : NULL;
    ecore_event_evas_seat_modifier_lock_update(lookup->evas, e->modifiers, seat);
 
@@ -516,6 +623,10 @@ _ecore_event_evas_mouse_button_cancel(Ecore_Event_Mouse_Button *e)
    lookup = _ecore_event_window_match(e->event_window);
    if (!lookup) return ECORE_CALLBACK_PASS_ON;
 
+   // TIZEN_ONLY(20180118): support a Ecore_Device
+   _ecore_event_device_check(lookup->evas, ECORE_EVENT_MOUSE_BUTTON_CANCEL, e, e->dev);
+   //
+
    INF("ButtonEvent cancel, device(%d), button(%d)", e->multi.device, e->buttons);
    if (!lookup->direct ||
        !lookup->direct(lookup->window, ECORE_EVENT_MOUSE_BUTTON_CANCEL, e))
@@ -544,6 +655,12 @@ _ecore_event_evas_mouse_button(Ecore_Event_Mouse_Button *e, Ecore_Event_Press pr
 
    lookup = _ecore_event_window_match(e->event_window);
    if (!lookup) return ECORE_CALLBACK_PASS_ON;
+   // TIZEN_ONLY(20180118): support a Ecore_Device
+   if (press == ECORE_DOWN)
+     _ecore_event_device_check(lookup->evas, ECORE_EVENT_MOUSE_BUTTON_DOWN, e, e->dev);
+   else
+     _ecore_event_device_check(lookup->evas, ECORE_EVENT_MOUSE_BUTTON_UP, e, e->dev);
+   //
    if (e->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK;
    if (e->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK;
    INF("\tButtonEvent:ecore_event_evas press(%d), device(%d), button(%d), fake(%d)", press, e->multi.device, e->buttons, faked);
@@ -686,6 +803,10 @@ ecore_event_evas_mouse_move(void *data EINA_UNUSED, int type EINA_UNUSED, void *
    lookup = _ecore_event_window_match(e->event_window);
    if (!lookup) return ECORE_CALLBACK_PASS_ON;
 
+   // TIZEN_ONLY(20180118): support a Ecore_Device
+   _ecore_event_device_check(lookup->evas, ECORE_EVENT_MOUSE_MOVE, e, e->dev);
+   //
+
    if (e->dev)
      {
         evas_device_push(lookup->evas, e->dev);
@@ -773,6 +894,13 @@ _ecore_event_evas_mouse_io(Ecore_Event_Mouse_IO *e, Ecore_Event_IO io)
    lookup = _ecore_event_window_match(e->event_window);
    if (!lookup) return ECORE_CALLBACK_PASS_ON;
 
+   // TIZEN_ONLY(20180118): support a Ecore_Device
+   if (io == ECORE_IN)
+     _ecore_event_device_check(lookup->evas, ECORE_EVENT_MOUSE_IN, e, e->dev);
+   else
+     _ecore_event_device_check(lookup->evas, ECORE_EVENT_MOUSE_OUT, e, e->dev);
+   //
+
    // TIZEN_ONLY ecore_input_evas: push an evas device if there is the device within an ecore input event
    if (e->dev)
      {
@@ -841,6 +969,9 @@ ecore_event_evas_mouse_wheel(void *data EINA_UNUSED, int type EINA_UNUSED, void
    e = event;
    lookup = _ecore_event_window_match(e->event_window);
    if (!lookup) return ECORE_CALLBACK_PASS_ON;
+   // TIZEN_ONLY(20180118): support a Ecore_Device
+   _ecore_event_device_check(lookup->evas, ECORE_EVENT_MOUSE_WHEEL, e, e->dev);
+   //
 
    if (e->dev)
      {
@@ -883,6 +1014,9 @@ ecore_event_evas_axis_update(void *data EINA_UNUSED, int type EINA_UNUSED, void
    e = event;
    lookup = _ecore_event_window_match(e->event_window);
    if (!lookup) return ECORE_CALLBACK_PASS_ON;
+   // TIZEN_ONLY(20180118): support a Ecore_Device
+   _ecore_event_device_check(lookup->evas, ECORE_EVENT_AXIS_UPDATE, e, e->dev);
+   //
    if (!lookup->direct ||
        !lookup->direct(lookup->window, ECORE_EVENT_AXIS_UPDATE, e))
      {
index 2d6efce..f4fc4f1 100644 (file)
@@ -314,36 +314,15 @@ _ecore_wl2_devices_get(const Ecore_Wl2_Input *input, int window_id)
    return NULL;
 }
 
-// TIZEN_ONLY(20180108): maintain a device list for each window
-static Eo *
-_ecore_wl2_tizen_devices_get(Ecore_Wl2_Tizen_Input_Device *tz_device, int window_id)
-{
-   Ecore_Wl2_Tizen_Input_Eo_Device *tz_dev;
-   Eina_List *l;
-
-   if (tz_device) return NULL;
-
-   EINA_LIST_FOREACH(tz_device->devices, l, tz_dev)
-     {
-        if (tz_dev->window_id == window_id)
-          return tz_dev->eo_dev;
-     }
-
-   return NULL;
-}
-//
-
 static Eo *
 _ecore_wl2_mouse_dev_get(Ecore_Wl2_Input *input, int window_id)
 {
    Ecore_Wl2_Input_Devices *devices;
    // TIZEN_ONLY(20171109): support a tizen_input_device_manager interface
-   Eo *dev;
 
-   if (input->devmgr.last_device_ptr)
+   if (input->devmgr.last_device_ptr && input->devmgr.last_device_ptr->device)
      {
-        dev = _ecore_wl2_tizen_devices_get(input->devmgr.last_device_ptr, window_id);
-        if (dev) return efl_ref(dev);
+        return efl_ref(input->devmgr.last_device_ptr->device);
      }
    //
 
@@ -359,12 +338,10 @@ _ecore_wl2_touch_dev_get(Ecore_Wl2_Input *input, int window_id)
 {
    Ecore_Wl2_Input_Devices *devices;
    // TIZEN_ONLY(20171109): support a tizen_input_device_manager interface
-   Eo *dev;
 
-   if (input->devmgr.last_device_touch)
+   if (input->devmgr.last_device_touch && input->devmgr.last_device_touch->device)
      {
-        dev = _ecore_wl2_tizen_devices_get(input->devmgr.last_device_touch, window_id);
-        if (dev) return efl_ref(dev);
+        return efl_ref(input->devmgr.last_device_touch->device);
      }
    //
 
@@ -387,15 +364,49 @@ _ecore_wl2_seat_dev_get(Ecore_Wl2_Input *input, int window_id)
    return NULL;
 }
 
+//TIZEN_ONLY(20180118): support a Ecore_Device
 static void
-_input_event_cb_free(void *data, void *event)
+_input_event_mouse_io_cb_free(void *data EINA_UNUSED, Ecore_Event_Mouse_IO *event)
 {
-   if (data)
-     efl_unref(data);
+   if (event->dev)
+     efl_unref(event->dev);
+   free(event);
+}
+
+static void
+_input_event_mouse_move_cb_free(void *data EINA_UNUSED, Ecore_Event_Mouse_Move *event)
+{
+   if (event->dev)
+     efl_unref(event->dev);
+   free(event);
+}
+
+static void
+_input_event_mouse_wheel_cb_free(void *data EINA_UNUSED, Ecore_Event_Mouse_Wheel *event)
+{
+   if (event->dev)
+     efl_unref(event->dev);
    free(event);
 }
 
 static void
+_input_event_mouse_button_cb_free(void *data EINA_UNUSED, Ecore_Event_Mouse_Button *event)
+{
+   if (event->dev)
+     efl_unref(event->dev);
+   free(event);
+}
+
+static void
+_input_event_key_cb_free(void *data EINA_UNUSED, Ecore_Event_Key *event)
+{
+   if (event->dev)
+     efl_unref(event->dev);
+   free(event);
+}
+//
+
+static void
 _ecore_wl2_input_mouse_in_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
 {
    Ecore_Event_Mouse_IO *ev;
@@ -411,7 +422,7 @@ _ecore_wl2_input_mouse_in_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
    ev->modifiers = input->keyboard.modifiers;
    ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
 
-   ecore_event_add(ECORE_EVENT_MOUSE_IN, ev, _input_event_cb_free, ev->dev);
+   ecore_event_add(ECORE_EVENT_MOUSE_IN, ev, _input_event_mouse_io_cb_free, ev->dev);
 }
 
 static void
@@ -430,7 +441,7 @@ _ecore_wl2_input_mouse_out_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window
    ev->modifiers = input->keyboard.modifiers;
    ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
 
-   ecore_event_add(ECORE_EVENT_MOUSE_OUT, ev, _input_event_cb_free, ev->dev);
+   ecore_event_add(ECORE_EVENT_MOUSE_OUT, ev, _input_event_mouse_io_cb_free, ev->dev);
 }
 
 static void
@@ -490,7 +501,7 @@ _ecore_wl2_input_mouse_move_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *windo
         info->sy = input->pointer.sy;
      }
 
-   ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _input_event_cb_free, ev->dev);
+   ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _input_event_mouse_move_cb_free, ev->dev);
 }
 
 static void
@@ -543,7 +554,7 @@ _ecore_wl2_input_mouse_wheel_send(Ecore_Wl2_Input *input, unsigned int axis, int
           ev->dev = _ecore_wl2_touch_dev_get(input, ev->window);
      }
 
-   ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _input_event_cb_free, ev->dev);
+   ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _input_event_mouse_wheel_cb_free, ev->dev);
 }
 
 static void
@@ -654,7 +665,7 @@ _ecore_wl2_input_mouse_down_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *windo
      }
 
    ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev,
-                   _input_event_cb_free, ev->dev);
+                   _input_event_mouse_button_cb_free, ev->dev);
 
    if ((info) && (!info->triple_click))
      {
@@ -729,7 +740,7 @@ _ecore_wl2_input_mouse_up_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window,
      ev->dev = _ecore_wl2_mouse_dev_get(input, window->id);
 
    ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev,
-                   _input_event_cb_free, ev->dev);
+                   _input_event_mouse_button_cb_free, ev->dev);
 
 
    // TIZEN_ONLY(20171109): support a tizen_input_device_manager interface
@@ -911,12 +922,10 @@ _ecore_wl2_keyboard_dev_get(Ecore_Wl2_Input *input, int window_id)
 {
    Ecore_Wl2_Input_Devices *devices;
    // TIZEN_ONLY(20171109): support a tizen_input_device_manager interface
-   Eo *dev;
 
-   if (input->devmgr.last_device_kbd)
+   if (input->devmgr.last_device_kbd && input->devmgr.last_device_kbd->device)
      {
-        dev = _ecore_wl2_tizen_devices_get(input->devmgr.last_device_kbd, window_id);
-        if (dev) return efl_ref(dev);
+        return efl_ref(input->devmgr.last_device_kbd->device);
      }
    //
 
@@ -977,9 +986,9 @@ _ecore_wl2_input_key_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window, xkb_
    /* DBG("Emitting Key event (%s,%s,%s,%s)\n", ev->keyname, ev->key, ev->compose, ev->string); */
 
    if (state)
-     ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, _input_event_cb_free, ev->dev);
+     ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, _input_event_key_cb_free, ev->dev);
    else
-     ecore_event_add(ECORE_EVENT_KEY_UP, ev, _input_event_cb_free, ev->dev);
+     ecore_event_add(ECORE_EVENT_KEY_UP, ev, _input_event_key_cb_free, ev->dev);
 }
 
 void
@@ -2160,13 +2169,13 @@ _ecore_wl2_input_device_last_device_set(Ecore_Wl2_Tizen_Input_Device *dev)
 
    switch(dev->clas)
      {
-      case EFL_INPUT_DEVICE_TYPE_MOUSE:
+      case ECORE_DEVICE_CLASS_MOUSE:
          input->devmgr.last_device_ptr = dev;
          break;
-      case EFL_INPUT_DEVICE_TYPE_KEYBOARD:
+      case ECORE_DEVICE_CLASS_KEYBOARD:
          input->devmgr.last_device_kbd = dev;
          break;
-      case EFL_INPUT_DEVICE_TYPE_TOUCH:
+      case ECORE_DEVICE_CLASS_TOUCH:
          input->devmgr.last_device_touch = dev;
          break;
       default:
@@ -2183,15 +2192,15 @@ _ecore_wl2_input_device_last_device_unset(Ecore_Wl2_Tizen_Input_Device *dev)
 
    switch(dev->clas)
      {
-      case EFL_INPUT_DEVICE_TYPE_MOUSE:
+      case ECORE_DEVICE_CLASS_MOUSE:
          if (input->devmgr.last_device_ptr == dev)
            input->devmgr.last_device_ptr = NULL;
          break;
-      case EFL_INPUT_DEVICE_TYPE_KEYBOARD:
+      case ECORE_DEVICE_CLASS_KEYBOARD:
          if (input->devmgr.last_device_kbd == dev)
            input->devmgr.last_device_kbd = NULL;
          break;
-      case EFL_INPUT_DEVICE_TYPE_TOUCH:
+      case ECORE_DEVICE_CLASS_TOUCH:
          if (input->devmgr.last_device_touch == dev)
            input->devmgr.last_device_touch = NULL;
          break;
@@ -2199,87 +2208,8 @@ _ecore_wl2_input_device_last_device_unset(Ecore_Wl2_Tizen_Input_Device *dev)
          break;
      }
 }
-
-static Eina_Bool
-_ecore_wl2_cb_tizen_device_event(void *data, int type, void *event)
-{
-   Ecore_Wl2_Tizen_Input_Device *devs, *dev = NULL;;
-   Ecore_Wl2_Event_Tizen_Input_Device_Info *ev = event;
-   Ecore_Wl2_Display *ewd = data;
-   Ecore_Wl2_Input *input;
-   Ecore_Wl2_Tizen_Input_Eo_Device *eo_dev;
-   Eina_List *l, *l_next;
-
-   input = ecore_wl2_input_default_input_get(ewd);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(input, ECORE_CALLBACK_PASS_ON);
-
-   EINA_LIST_FOREACH(input->devmgr.devices, l, devs)
-     {
-        if (!strncmp(devs->identifier, ev->identifier, strlen(ev->identifier)))
-          {
-             dev = devs;
-             break;
-          }
-     }
-
-   if (type == ECORE_WL2_EVENT_TIZEN_INPUT_DEVICE_ADDED)
-     {
-        if (!dev) return ECORE_CALLBACK_PASS_ON;
-        /* FIXME: If dev is not exist, this device is not originate from tizen_input_device.
-         *        How process this device? Ignore or Make a new device
-         */
-
-        EINA_LIST_FOREACH(dev->devices, l, eo_dev)
-          {
-             if (eo_dev->eo_dev == ev->dev)
-               return ECORE_CALLBACK_PASS_ON;
-          }
-
-        eo_dev = (Ecore_Wl2_Tizen_Input_Eo_Device *)calloc(1, sizeof(Ecore_Wl2_Tizen_Input_Eo_Device));
-        if (!eo_dev) return ECORE_CALLBACK_PASS_ON;
-
-        eo_dev->eo_dev = efl_ref(ev->dev);
-        eo_dev->window_id = ev->window_id;
-
-        dev->devices = eina_list_append(dev->devices, eo_dev);
-
-        return ECORE_CALLBACK_PASS_ON;
-     }
-   else if (type == ECORE_WL2_EVENT_TIZEN_INPUT_DEVICE_REMOVED)
-     {
-        if (!dev) return ECORE_CALLBACK_PASS_ON;
-
-        EINA_LIST_FOREACH_SAFE(dev->devices, l, l_next, eo_dev)
-          {
-             if (eo_dev->eo_dev == ev->dev)
-               {
-                  efl_unref(eo_dev->eo_dev);
-                  eo_dev->eo_dev = NULL;
-                  dev->devices = eina_list_remove_list(dev->devices, l);
-                  free(eo_dev);
-                  break;
-               }
-          }
-
-        if (eina_list_count(dev->devices) == 0)
-          {
-             _ecore_wl2_input_device_last_device_unset(dev);
-
-             if (dev->tz_device) tizen_input_device_release(dev->tz_device);
-             if (dev->name) eina_stringshare_del(dev->name);
-             if (dev->identifier) eina_stringshare_del(dev->identifier);
-             dev->seat = NULL;
-
-             input->devmgr.devices = eina_list_remove(input->devmgr.devices, dev);
-             free(dev);
-          }
-     }
-
-   return ECORE_CALLBACK_PASS_ON;
-}
 //
 
-
 void
 _ecore_wl2_input_add(Ecore_Wl2_Display *display, unsigned int id, unsigned int version)
 {
@@ -2318,16 +2248,6 @@ _ecore_wl2_input_add(Ecore_Wl2_Display *display, unsigned int id, unsigned int v
      ecore_event_handler_add(ECORE_WL2_EVENT_DEVICE_REMOVED,
                              _ecore_wl2_cb_device_event, input);
 
-   // TIZEN_ONLY(20171109): support a tizen_input_device_manager interface
-   input->tzdev_add_handler =
-     ecore_event_handler_add(ECORE_WL2_EVENT_TIZEN_INPUT_DEVICE_ADDED,
-                             _ecore_wl2_cb_tizen_device_event, display);
-
-   input->tzdev_remove_handler =
-     ecore_event_handler_add(ECORE_WL2_EVENT_TIZEN_INPUT_DEVICE_REMOVED,
-                             _ecore_wl2_cb_tizen_device_event, display);
-   //
-
    if (!display->wl.data_device_manager) return;
 
    input->data.device =
@@ -3114,7 +3034,7 @@ _ecore_wl2_input_device_info_free(void *data EINA_UNUSED, void *ev)
 }
 
 void
-_ecore_wl2_input_device_info_send(Ecore_Wl2_Display *dpy, const char *name,  const char *identifier, Efl_Input_Device_Type clas, Efl_Input_Device_Subtype subclas, Eina_Bool flag)
+_ecore_wl2_input_device_info_send(Ecore_Wl2_Display *dpy, const char *name,  const char *identifier, Ecore_Device_Class clas, Ecore_Device_Subclass subclas, Eina_Bool flag)
 {
    Ecore_Wl2_Event_Tizen_Device_Info *e;
 
@@ -3134,12 +3054,72 @@ _ecore_wl2_input_device_info_send(Ecore_Wl2_Display *dpy, const char *name,  con
 }
 
 static void
-_ecore_wl2_input_device_info_broadcast(Ecore_Wl2_Input *input, const char *name, const char *identifier, Efl_Input_Device_Type clas, Efl_Input_Device_Subtype subclas, Eina_Bool flag)
+_ecore_wl2_input_device_ecore_device_add(Ecore_Wl2_Tizen_Input_Device *dev)
+{
+   Ecore_Device *ecdev;
+   Eina_List *l;
+   const char *ecdev_name;
+
+   if (!dev->identifier) return;
+
+   EINA_LIST_FOREACH(ecore_device_list(), l, ecdev)
+     {
+        ecdev_name = ecore_device_identifier_get(ecdev);
+        if (!ecdev_name) continue;
+        if ((ecore_device_class_get(ecdev) == dev->clas) && (!strcmp(ecdev_name, dev->identifier)))
+          return;
+     }
+
+   ecdev = ecore_device_add();
+   if (!ecdev)
+     {
+        ERR("Failed to add ecore device for name: %s (%s)\n", dev->name, dev->identifier);
+        return;
+     }
+   ecore_device_name_set(ecdev, dev->name);
+   ecore_device_identifier_set(ecdev, dev->identifier);
+   ecore_device_class_set(ecdev, dev->clas);
+   ecore_device_subclass_set(ecdev, dev->subclas);
+
+   dev->device = efl_ref(ecdev);
+}
+
+static void
+_ecore_wl2_input_device_ecore_device_remove(Ecore_Wl2_Tizen_Input_Device *dev)
 {
-   if (!name) return;
-   if (!input || !input->display) return;
+   Ecore_Device *ecdev;
+   const Eina_List *l;
+   const char *ecdev_name;
 
-   _ecore_wl2_input_device_info_send(input->display, name, identifier, clas, subclas, flag);
+   if (!dev->identifier) return;
+
+   EINA_LIST_FOREACH(ecore_device_list(), l, ecdev)
+     {
+        ecdev_name = ecore_device_identifier_get(ecdev);
+        if (!ecdev_name) continue;
+        if ((ecore_device_class_get(ecdev) == dev->clas) &&
+            (!strcmp(ecdev_name, dev->identifier)))
+           {
+              ecore_device_del(ecdev);
+              dev->device = NULL;
+              return;
+           }
+      }
+}
+
+static void
+_ecore_wl2_input_device_info_broadcast(Ecore_Wl2_Tizen_Input_Device *dev, Eina_Bool flag)
+{
+   if (!dev) return;
+   if (!dev->name) return;
+   if (!dev->input || !dev->input->display) return;
+
+   _ecore_wl2_input_device_info_send(dev->input->display, dev->name, dev->identifier, dev->clas, dev->subclas, flag);
+
+   if (flag)
+     _ecore_wl2_input_device_ecore_device_add(dev);
+   else
+     _ecore_wl2_input_device_ecore_device_remove(dev);
 }
 
 static void
@@ -3148,11 +3128,11 @@ _ecore_wl2_input_device_cb_device_info(void *data, struct tizen_input_device *ti
    Ecore_Wl2_Tizen_Input_Device *dev;
 
    if (!(dev = data)) return;
-   dev->clas = (Efl_Input_Device_Type)clas;
-   dev->subclas = (Efl_Input_Device_Subtype)subclas;
+   dev->clas = (Ecore_Device_Class)clas;
+   dev->subclas = (Ecore_Device_Subclass)subclas;
    dev->name = eina_stringshare_add(name);
 
-   _ecore_wl2_input_device_info_broadcast(dev->input, dev->name, dev->identifier, dev->clas, dev->subclas, EINA_TRUE);
+   _ecore_wl2_input_device_info_broadcast(dev, EINA_TRUE);
 }
 
 static void
@@ -3264,7 +3244,7 @@ _ecore_wl2_input_device_manager_cb_device_remove(void *data, struct tizen_input_
 {
    Ecore_Wl2_Display *ewd = (Ecore_Wl2_Display *)data;
    Ecore_Wl2_Input *input;
-   Eina_List *l;
+   Eina_List *l, *l_next;
    Ecore_Wl2_Tizen_Input_Device *dev;
 
    if (!ewd) return;
@@ -3274,12 +3254,23 @@ _ecore_wl2_input_device_manager_cb_device_remove(void *data, struct tizen_input_
 
    if (!input) return;
 
-   EINA_LIST_FOREACH(input->devmgr.devices, l, dev)
+   EINA_LIST_FOREACH_SAFE(input->devmgr.devices, l, l_next, dev)
      {
         if (!dev->identifier) continue;
         if ((!strcmp(dev->identifier, identifier)) && (seat == dev->seat) && (device == dev->tz_device))
           {
-             _ecore_wl2_input_device_info_broadcast(dev->input, dev->name, dev->identifier, dev->clas, dev->subclas, EINA_FALSE);
+             _ecore_wl2_input_device_info_broadcast(dev, EINA_FALSE);
+
+             _ecore_wl2_input_device_last_device_unset(dev);
+
+             if (dev->tz_device) tizen_input_device_release(dev->tz_device);
+             if (dev->name) eina_stringshare_del(dev->name);
+             if (dev->identifier) eina_stringshare_del(dev->identifier);
+             dev->seat = NULL;
+
+             input->devmgr.devices = eina_list_remove_list(input->devmgr.devices, l);
+
+             free(dev);
              break;
           }
      }
index 3ded1c6..1d5e0c4 100755 (executable)
@@ -412,10 +412,10 @@ struct _Ecore_Wl2_Tizen_Input_Device
    Ecore_Wl2_Input *input;
    const char *name;
    const char *identifier;
-   Efl_Input_Device_Type clas;
-   Efl_Input_Device_Subtype subclas;
+   Ecore_Device_Class clas;
+   Ecore_Device_Subclass subclas;
    struct wl_seat *seat;
-   Eina_List *devices;
+   Ecore_Device *device;
 };
 
 typedef struct _Ecore_Wl2_Touch_Axis
index 6ed0752..b8d94de 100644 (file)
@@ -29,6 +29,7 @@ set(PUBLIC_EO_FILES
   interfaces/efl_image_animated.eo
   interfaces/efl_image_load.eo
   interfaces/efl_input_device.eo
+  interfaces/efl_ecore_input_device.eo
   interfaces/efl_input_types.eot
   interfaces/efl_io_buffer.eo
   interfaces/efl_io_closer.eo
@@ -80,6 +81,7 @@ set(SOURCES
   interfaces/efl_vpath_core.c
   interfaces/efl_vpath_file_core.c
   interfaces/efl_input_device.c
+  interfaces/efl_ecore_input_device.c
   interfaces/efl_io_closer.c
   interfaces/efl_io_positioner.c
   interfaces/efl_io_reader.c
index fac7a99..9e95c8a 100644 (file)
@@ -136,6 +136,7 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command;
 /* Input events */
 #include "interfaces/efl_input_types.eot.h"
 #include "interfaces/efl_input_device.eo.h"
+#include "interfaces/efl_ecore_input_device.eo.h"
 
 /* Canvas & UI */
 #include "interfaces/efl_canvas.eo.h"
@@ -188,6 +189,7 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command;
 #include "interfaces/efl_image.eo.legacy.h"
 #include "interfaces/efl_image_animated.eo.legacy.h"
 #include "interfaces/efl_input_device.eo.legacy.h"
+#include "interfaces/efl_ecore_input_device.eo.legacy.h"
 #include "interfaces/efl_text_types.eot.h"
 #endif
 
index a83edf1..848f719 100644 (file)
@@ -16,6 +16,9 @@
 typedef struct _Efl_Input_Pointer_Data  Efl_Input_Pointer_Data;
 typedef struct _Efl_Input_Key_Data      Efl_Input_Key_Data;
 typedef struct _Efl_Input_Device_Data   Efl_Input_Device_Data;
+// TIZEN_ONLY(20180118): support a Ecore_Device
+typedef struct _Efl_Ecore_Input_Device_Data   Efl_Ecore_Input_Device_Data;
+//
 typedef struct _Efl_Input_Hold_Data     Efl_Input_Hold_Data;
 typedef struct _Efl_Input_Focus_Data    Efl_Input_Focus_Data;
 
@@ -98,6 +101,19 @@ struct _Efl_Input_Device_Data
    unsigned int      pointer_count;
 };
 
+// TIZEN_ONLY(20180118): support a Ecore_Device
+struct _Efl_Ecore_Input_Device_Data
+{
+   Eo               *eo;
+   Efl_Ecore_Input_Device *source;  /* ref */
+   Eina_List        *children; /* ref'ed by efl_parent, not by this list */
+   unsigned int      id;
+   Efl_Ecore_Input_Device_Type klass;
+   unsigned int      subclass; // Evas_Device_Subclass (unused)
+   unsigned int      pointer_count;
+};
+//
+
 struct _Efl_Input_Hold_Data
 {
    Eo               *eo;
diff --git a/src/lib/efl/interfaces/efl_ecore_input_device.c b/src/lib/efl/interfaces/efl_ecore_input_device.c
new file mode 100644 (file)
index 0000000..7642db9
--- /dev/null
@@ -0,0 +1,220 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <Efl.h>
+
+#define EFL_INTERNAL_UNSTABLE
+#include "efl_common_internal.h"
+
+#define MY_CLASS EFL_ECORE_INPUT_DEVICE_CLASS
+
+/* Efl Input Device = Evas Device */
+
+typedef struct _Child_Device_Iterator Child_Device_Iterator;
+
+struct _Child_Device_Iterator
+{
+   Eina_Iterator  iterator;
+   Eina_List     *list;
+   Eina_Iterator *real_iterator;
+   Eo            *object;
+};
+
+static Eina_Bool
+_is_pointer(Efl_Ecore_Input_Device_Data *pd)
+{
+   return (pd->klass == EFL_ECORE_INPUT_DEVICE_TYPE_MOUSE ||
+           pd->klass == EFL_ECORE_INPUT_DEVICE_TYPE_TOUCH ||
+           pd->klass == EFL_ECORE_INPUT_DEVICE_TYPE_PEN ||
+           pd->klass == EFL_ECORE_INPUT_DEVICE_TYPE_WAND);
+}
+
+static void
+_seat_pointers_update(Efl_Ecore_Input_Device_Data *seat, Efl_Ecore_Input_Device_Data *dev)
+{
+   if (seat && _is_pointer(dev))
+     seat->pointer_count++;
+}
+
+EOLIAN static Efl_Object *
+_efl_ecore_input_device_efl_object_constructor(Eo *obj, Efl_Ecore_Input_Device_Data *pd)
+{
+   obj = efl_constructor(efl_super(obj, MY_CLASS));
+   pd->eo = obj;
+   return obj;
+}
+
+EOLIAN static void
+_efl_ecore_input_device_efl_object_destructor(Eo *obj, Efl_Ecore_Input_Device_Data *pd)
+{
+   pd->children = eina_list_free(pd->children);
+   if (pd->klass != EFL_ECORE_INPUT_DEVICE_TYPE_SEAT)
+     {
+        Efl_Ecore_Input_Device_Data *p;
+        Eo *seat;
+
+        seat = efl_ecore_input_device_seat_get(obj);
+        p = efl_data_scope_get(seat, MY_CLASS);
+        if (p) p->children = eina_list_remove(p->children, obj);
+     }
+   efl_unref(pd->source);
+
+   return efl_destructor(efl_super(obj, MY_CLASS));
+}
+
+EOLIAN static void
+_efl_ecore_input_device_efl_object_parent_set(Eo *obj, Efl_Ecore_Input_Device_Data *pd EINA_UNUSED, Eo *parent)
+{
+   Efl_Ecore_Input_Device_Data *p;
+
+   if (parent)
+     {
+        if (efl_isa(parent, MY_CLASS))
+          {
+             p = efl_data_scope_get(parent, MY_CLASS);
+             EINA_SAFETY_ON_FALSE_RETURN(p->klass == EFL_ECORE_INPUT_DEVICE_TYPE_SEAT);
+             if (!eina_list_data_find(p->children, obj))
+               {
+                  p->children = eina_list_append(p->children, obj);
+                  _seat_pointers_update(p, pd);
+               }
+          }
+        else if(!efl_isa(parent, EFL_CANVAS_INTERFACE))
+          {
+             EINA_SAFETY_ERROR("The parent of a device must be a seat or the canvas");
+             return;
+          }
+     }
+   else
+     {
+        Eo *old_parent = efl_parent_get(obj);
+        if (old_parent && efl_isa(old_parent, MY_CLASS))
+          {
+             p = efl_data_scope_get(old_parent, MY_CLASS);
+             p->children = eina_list_remove(p->children, obj);
+             if (_is_pointer(pd))
+               p->pointer_count--;
+          }
+     }
+
+   efl_parent_set(efl_super(obj, MY_CLASS), parent);
+}
+
+EOLIAN static void
+_efl_ecore_input_device_device_type_set(Eo *obj, Efl_Ecore_Input_Device_Data *pd, Efl_Ecore_Input_Device_Type klass)
+{
+   EINA_SAFETY_ON_TRUE_RETURN(pd->klass);
+   pd->klass = klass;
+   if (klass != EFL_ECORE_INPUT_DEVICE_TYPE_SEAT)
+     {
+        Efl_Ecore_Input_Device_Data *seat = efl_data_scope_get(efl_ecore_input_device_seat_get(obj), MY_CLASS);
+        _seat_pointers_update(seat, pd);
+     }
+}
+
+EOLIAN static Efl_Ecore_Input_Device_Type
+_efl_ecore_input_device_device_type_get(Eo *obj EINA_UNUSED, Efl_Ecore_Input_Device_Data *pd)
+{
+   return pd->klass;
+}
+
+EOLIAN static void
+_efl_ecore_input_device_source_set(Eo *obj EINA_UNUSED, Efl_Ecore_Input_Device_Data *pd, Efl_Ecore_Input_Device *src)
+{
+   if (pd->source == src) return;
+   efl_unref(pd->source);
+   pd->source = efl_ref(src);
+}
+
+EOLIAN static Efl_Ecore_Input_Device *
+_efl_ecore_input_device_source_get(Eo *obj EINA_UNUSED, Efl_Ecore_Input_Device_Data *pd)
+{
+   return pd->source;
+}
+
+EOLIAN static void
+_efl_ecore_input_device_seat_id_set(Eo *obj EINA_UNUSED, Efl_Ecore_Input_Device_Data *pd, unsigned int id)
+{
+   EINA_SAFETY_ON_TRUE_RETURN(pd->klass != EFL_ECORE_INPUT_DEVICE_TYPE_SEAT);
+   pd->id = id;
+}
+
+EOLIAN static unsigned int
+_efl_ecore_input_device_seat_id_get(Eo *obj, Efl_Ecore_Input_Device_Data *pd)
+{
+   if (pd->klass == EFL_ECORE_INPUT_DEVICE_TYPE_SEAT)
+     return pd->id;
+   return efl_ecore_input_device_seat_id_get(efl_ecore_input_device_seat_get(obj));
+}
+
+EOLIAN static Efl_Ecore_Input_Device *
+_efl_ecore_input_device_seat_get(Eo *obj, Efl_Ecore_Input_Device_Data *pd)
+{
+   for (; obj; obj = efl_parent_get(obj))
+     {
+        if (pd->klass == EFL_ECORE_INPUT_DEVICE_TYPE_SEAT)
+          return pd->eo;
+
+        if (!efl_isa(obj, MY_CLASS)) break;
+        pd = efl_data_scope_get(obj, MY_CLASS);
+     }
+
+   return NULL;
+}
+
+static Eina_Bool
+_child_device_iterator_next(Child_Device_Iterator *it, void **data)
+{
+   Eo *sub;
+
+   if (!eina_iterator_next(it->real_iterator, (void **) &sub))
+     return EINA_FALSE;
+
+   if (data) *data = sub;
+   return EINA_TRUE;
+}
+
+static Eo *
+_child_device_iterator_get_container(Child_Device_Iterator *it)
+{
+   return it->object;
+}
+
+static void
+_child_device_iterator_free(Child_Device_Iterator *it)
+{
+   eina_iterator_free(it->real_iterator);
+   free(it);
+}
+
+EOLIAN static Eina_Iterator *
+_efl_ecore_input_device_children_iterate(Eo *obj, Efl_Ecore_Input_Device_Data *pd)
+{
+   Child_Device_Iterator *it;
+
+   it = calloc(1, sizeof(*it));
+   if (!it) return NULL;
+
+   EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+
+   it->list = pd->children;
+   it->real_iterator = eina_list_iterator_new(it->list);
+   it->iterator.version = EINA_ITERATOR_VERSION;
+   it->iterator.next = FUNC_ITERATOR_NEXT(_child_device_iterator_next);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_child_device_iterator_get_container);
+   it->iterator.free = FUNC_ITERATOR_FREE(_child_device_iterator_free);
+   it->object = obj;
+
+   return &it->iterator;
+}
+
+EOLIAN static unsigned int
+_efl_ecore_input_device_has_pointer_caps(Eo *obj EINA_UNUSED, Efl_Ecore_Input_Device_Data *pd)
+{
+   if (pd->klass == EFL_ECORE_INPUT_DEVICE_TYPE_SEAT)
+     return pd->pointer_count;
+   return _is_pointer(pd);
+}
+
+#include "interfaces/efl_ecore_input_device.eo.c"
diff --git a/src/lib/efl/interfaces/efl_ecore_input_device.eo b/src/lib/efl/interfaces/efl_ecore_input_device.eo
new file mode 100644 (file)
index 0000000..2e3554a
--- /dev/null
@@ -0,0 +1,118 @@
+enum Efl.Ecore.Input.Device.Type
+{
+   [[General type of input device.
+
+     Legacy support since 1.8 as $Evas_Device_Class.
+   ]]
+   none,     [[Not a device.]]
+   seat,     [[The user/seat (the user themselves).]]
+   keyboard, [[A regular keyboard, numberpad or attached buttons.]]
+   mouse,    [[A mouse, trackball or touchpad relative motion device.]]
+   touch,    [[A touchscreen with fingers or stylus.]]
+   pen,      [[A special pen device.]]
+   wand,     [[A laser pointer, wii-style or "Minority Report" pointing device.]]
+   gamepad,  [[A gamepad controller or joystick.]]
+}
+
+// TIZEN_ONLY(20171109): support a tizen_input_device_manager interface
+enum Efl.Ecore.Input.Device.Subtype
+{
+   [[General type of input device.
+
+     Legacy support since 1.8 as $Evas_Device_Subclass.
+   ]]
+   none,     [[Not a device.]]
+   finger,     [[The normal flat of your finger.]]
+   fingernail, [[A fingernai.]]
+   knuckle,    [[A Knuckle.]]
+   palm,    [[The palm of a users hand.]]
+   hand_size,      [[The side of your hand.]]
+   hand_flat,     [[The flat of your hand.]]
+   pen_tip,  [[The tip of a pen.]]
+   trackpad,  [[A trackpad style mouse.]]
+   trackpoint,  [[A trackpoint style mouse.]]
+   trackball,  [[A trackball style mouse.]]
+// TIZEN_ONLY(20170620): Add new device subclasses.
+   remocon,  [[A remote controller.]]
+   virtual_keyboard,  [[A virtual keyboard.]]
+//
+}
+//
+
+/* TODO: Add canvas property. Current problem is we need to return
+         Efl.Ui.Win and not Evas:
+  @property canvas { values { canvas: Efl.Canvas; } }
+*/
+
+class Efl.Ecore.Input.Device (Efl.Object)
+{
+   [[Represents a pointing device such as a touch finger, pen or mouse.
+
+     @since 1.18
+   ]]
+   methods {
+      @property device_type {
+         [[Device type property]]
+         values {
+            klass: Efl.Ecore.Input.Device.Type; [[Input device class]]
+         }
+      }
+      @property source {
+         [[Device source property]]
+         values {
+            src: Efl.Ecore.Input.Device; [[Input device]]
+         }
+      }
+      @property seat {
+         [[Get the @Efl.Ecore.Input.Device that represents a seat.
+
+           This method will find the seat the device belongs to.
+
+           For this, it walk through device's parents looking for a device
+           with @Efl.Ecore.Input.Device.Type.seat. It may be
+           the device itself.
+
+           In case no seat is found, $null is returned.
+         ]]
+         get {}
+         values {
+            seat: Efl.Ecore.Input.Device; [[The seat this device belongs to.]]
+         }
+      }
+      @property seat_id {
+         [[Seat id number
+
+           @since 1.20
+         ]]
+          values {
+             id: uint; [[The id of the seat]]
+          }
+      }
+      children_iterate {
+         [[Lists the children attached to this device.
+
+           This is only meaningful with seat devices, as they are groups of
+           real input devices.
+
+           @since 1.20
+         ]]
+         return: iterator<const(Efl.Ecore.Input.Device)> @owned; [[List of device children]]
+      }
+      has_pointer_caps {
+         [[Determine whether a device has pointer capabilities.
+
+           Returns 1 for Mouse, Touch, Pen, Pointer, and Wand type devices.
+
+           If a seat device is passed returns the number of pointer devices in the seat.
+
+           @since 1.20
+         ]]
+         return: uint; [[Pointer caps]]
+      }
+   }
+   implements {
+      Efl.Object.constructor;
+      Efl.Object.destructor;
+      Efl.Object.parent { set; }
+   }
+}
index 083434e..4241bba 100644 (file)
@@ -1225,6 +1225,7 @@ EAPI const Evas_Device *evas_device_emulation_source_get(const Evas_Device *dev)
 //TIZEN_ONLY(20171220): send a hw device for pointer events
 EAPI Evas_Device *evas_device_top_get(const Evas *eo_e);
 //
+EAPI Evas_Device *evas_device_default_get(const Evas *eo_e, Evas_Device_Class clas);
 
 /**
  * @}
index e4b61d3..798073f 100644 (file)
@@ -524,3 +524,29 @@ evas_device_top_get(const Evas *eo_e)
    return _evas_device_top_get(eo_e);
 }
 //
+
+EAPI Evas_Device *
+evas_device_default_get(const Evas *eo_e, Evas_Device_Class clas)
+{
+   Evas_Public_Data *e;
+
+   SAFETY_CHECK(eo_e, EVAS_CANVAS_CLASS, NULL);
+
+   e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
+
+   if (clas == EVAS_DEVICE_CLASS_SEAT)
+     {
+        return e->default_seat;
+     }
+   else if (clas == EVAS_DEVICE_CLASS_KEYBOARD)
+     {
+        return e->default_keyboard;
+     }
+   else if (clas == EVAS_DEVICE_CLASS_MOUSE ||
+            clas == EVAS_DEVICE_CLASS_TOUCH)
+     {
+        return e->default_mouse;
+     }
+
+   return NULL;
+}
index 03b0aab..527a61b 100644 (file)
@@ -1514,22 +1514,6 @@ _ecore_evas_wl_common_evas_device_find(Evas *evas, const char *identifier)
    return EINA_FALSE;
 }
 
-static void
-_ecore_evas_wl_common_tizen_device_event_add(int type, Evas_Device *dev, Ecore_Evas *ee)
-{
-   Ecore_Wl2_Event_Tizen_Input_Device_Info *ev;
-
-   ev = calloc(1, sizeof(Ecore_Wl2_Event_Tizen_Input_Device_Info));
-   EINA_SAFETY_ON_NULL_RETURN(ev);
-
-   ev->dev = efl_ref(dev);
-   ev->name = evas_device_name_get(dev);
-   ev->identifier = evas_device_description_get(dev);
-   ev->window_id = ee->prop.window;
-
-   ecore_event_add(type, ev, NULL, dev);
-}
-
 static Evas_Device *
 _ecore_evas_wl_common_default_seat_get(Evas *evas)
 {
@@ -1575,7 +1559,6 @@ _ecore_evas_wl_common_cb_tizen_device_add(void *data EINA_UNUSED, int type EINA_
                                            seat, NULL,
                                            ev->clas,
                                            ev->subclas);
-        _ecore_evas_wl_common_tizen_device_event_add(ECORE_WL2_EVENT_TIZEN_INPUT_DEVICE_ADDED, device, ee);
      }
 
    return ECORE_CALLBACK_PASS_ON;
@@ -1603,7 +1586,6 @@ _ecore_evas_wl_common_cb_tizen_device_del(void *data EINA_UNUSED, int type EINA_
           {
              if (!strncmp(evas_device_description_get(device), ev->identifier, strlen(ev->identifier)))
                {
-                  _ecore_evas_wl_common_tizen_device_event_add(ECORE_WL2_EVENT_TIZEN_INPUT_DEVICE_REMOVED, device, ee);
                   evas_device_del(device);
                }
           }