From 1c0707d8f297df00f703e16141de5a30d128ab31 Mon Sep 17 00:00:00 2001 From: Duna Oh Date: Fri, 25 Mar 2016 18:58:38 +0900 Subject: [PATCH] Ecore: introduce Ecore_Device and apply to Ecore_Event - change (const char *)dev_name to (Ecore_Device *)dev in Ecore_Events - use Ecore_Event_Mouse_IO instead of Ecore_Wl_Mouse_In/Out - don't need to call evas_event_feed_mouse_in/out in ecore_evas_wayland. ecore_input_evas does the same job. Signed-off-by: Duna Oh Change-Id: I89c329962f4228eed73f5aebd1a5b3df20c2cf55 --- src/Makefile_Ecore.am | 1 + src/lib/ecore/Ecore_Common.h | 213 +++++++++++++++++++++ src/lib/ecore/ecore.c | 5 + src/lib/ecore/ecore_device.c | 190 ++++++++++++++++++ src/lib/ecore/ecore_private.h | 4 + src/lib/ecore_drm/Ecore_Drm.h | 3 +- src/lib/ecore_drm/ecore_drm_device.c | 2 +- src/lib/ecore_drm/ecore_drm_evdev.c | 35 +++- src/lib/ecore_drm/ecore_drm_inputs.c | 135 ++++++++++++- src/lib/ecore_drm/ecore_drm_private.h | 2 +- src/lib/ecore_input/Ecore_Input.h | 46 ++--- src/lib/ecore_input_evas/ecore_input_evas.c | 120 ++++-------- src/lib/ecore_wayland/ecore_wl_input.c | 152 ++++++++++++--- .../engines/wayland/ecore_evas_wayland_common.c | 14 +- 14 files changed, 771 insertions(+), 151 deletions(-) create mode 100644 src/lib/ecore/ecore_device.c diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am index b7e0b6b..12c8b66 100644 --- a/src/Makefile_Ecore.am +++ b/src/Makefile_Ecore.am @@ -68,6 +68,7 @@ lib/ecore/ecore_thread.c \ lib/ecore/ecore_throttle.c \ lib/ecore/ecore_exe.c \ lib/ecore/ecore_exe_private.h \ +lib/ecore/ecore_device.c \ lib/ecore/ecore_private.h if HAVE_WIN32 diff --git a/src/lib/ecore/Ecore_Common.h b/src/lib/ecore/Ecore_Common.h index 0723fdc..d969013 100644 --- a/src/lib/ecore/Ecore_Common.h +++ b/src/lib/ecore/Ecore_Common.h @@ -3188,6 +3188,219 @@ typedef Eo Ecore_Job; /**< A job handle */ * @} */ +/** + * @defgroup Ecore_Device_Group Ecore Device functions + * @ingroup Ecore + * + * @{ + */ + typedef struct _Ecore_Device 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 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; /**< A general subclass of device @since 1.18 */ + +typedef struct _Ecore_Device_Event_Info Ecore_Device_Event_Info; /**< @since 1.18 */ + +/** Add a new device type + * + * Adds a new device node. All devices created whenever a new device + * is plugged and will be removed whenever it gets unplugged. + * + * @return the device node created or NULL if an error occurred. + * + * @see ecore_device_del + * @since 1.18 + */ +EAPI Ecore_Device *ecore_device_add(); + +/** + * Delete a new device type + * + * @param dev The device node you want to delete. + * + * @since 1.18 + */ +EAPI void ecore_device_del(Ecore_Device *dev); + +/** + * List all current devices + * + * @return An internal list of Ecore_Device pointers, or NULL if no devices are found + * + * This will list all devices allowing you to walk the device tree. + * + * If there are no devices, NULL is returned. + * + * @see evas_device_name_get + * @see evas_device_description_get + * @see ecore_device_identifier_get + * @see evas_device_class_get + * @see evas_device_subclass_get + * @since 1.8 + */ +EAPI const Eina_List *ecore_device_list(void); + +/** + * Set the name of a device as a string + * + * @p dev The device to set the name of + * @p name The name string as a readable C UTF8 string + * + * @since 1.8 + */ +EAPI void ecore_device_name_set(Ecore_Device *dev, const char *name); + +/** + * Get the name of a device + * + * @p dev The device to query + * @return The device name string or NULL if none is set + * + * This gets the name set by ecore_device_name_set(). This is a readable UTF8 + * C string, or NULL if no name is set. + * + * The name should be a short name like "Wireless Mouse", "Joystick", + * "Finger", "Keyboard" or "Numberpad" etc. + * + * @since 1.8 + */ +EAPI const char *ecore_device_name_get(const Ecore_Device *dev); + +/** + * Set the description of a device as a string + * + * @p dev The device to set the description of + * @p desc The description string as a readable C UTF8 string + * + * @since 1.8 + */ +EAPI void ecore_device_description_set(Ecore_Device *dev, const char *desc); + +/** + * Get the description of a device + * + * @p dev The device to query + * @return The device description string or NULL if none is set + * + * This gets the description set by ecore_device_description_set(). This is + * a readable UTF8 C string, or NULL if no description is set. + * + * A description is meant to be a longer string describing the device so a + * human may make sense of it. For example "Wireless 6 button mouse in Black + * with red buttons" would be a good description, so a user may identify + * precisely which device is being talked about. + * + * @since 1.8 + */ +EAPI const char *ecore_device_description_get(const Ecore_Device *dev); + +/** + * Set the identifier of a device as a string + * + * @p dev The device to set the identifier of + * @p identifier The identifier string as a readable C UTF8 string + * + * @since 1.8 + */ +EAPI void ecore_device_identifier_set(Ecore_Device *dev, const char *desc); + +/** + * Get the identifier of a device + * + * @p dev The device to query + * @return The device identifier string or NULL if none is set + * + * This gets the identifier set by ecore_device_identifier_set(). This is + * a readable UTF8 C string, or NULL if no identifier is set. + * + * A identifier should be unique string distinguishing input devices. + * For now, the sys name of device provided by udev is used. ex)/dev/input/event2. + * + * @since 1.8 + */ +EAPI const char *ecore_device_identifier_get(const Ecore_Device *dev); + +/** + * Set the major class of device + * + * @param dev The device whose class to set + * @param clas The class to set it to + * + * This sets the "primary" class of device (a broad thing like mouse, keyboard, + * touch, pen etc.). + * + * @since 1.8 + */ +EAPI void ecore_device_class_set(Ecore_Device *dev, Ecore_Device_Class clas); + +/** + * Get the major class of a device + * + * @param dev The devise to query + * @return The device class to set + * + * This sets the device class set by evas_device_class_set(). + * + * @since 1.8 + */ +EAPI Ecore_Device_Class ecore_device_class_get(const Ecore_Device *dev); + +/** + * Set the sub-class of a device + * + * @param dev The device to modify + * @param clas The sub-class to set + * + * This sets the sub-class of a device which gives much more detailed usage + * within a broader category. + * + * @since 1.8 + */ +EAPI void ecore_device_subclass_set(Ecore_Device *dev, Ecore_Device_Subclass clas); + +/** + * Get the device sub-class + * + * @param dev The device to query + * @return The device sub-class set by evas_device_subclass_set(). + * + * @since 1.8 + */ +EAPI Ecore_Device_Subclass ecore_device_subclass_get(const Ecore_Device *dev); + +/** + * @} + */ #ifdef __cplusplus } #endif diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c index f121258..4911bee 100644 --- a/src/lib/ecore/ecore.c +++ b/src/lib/ecore/ecore.c @@ -356,6 +356,7 @@ ecore_shutdown(void) _ecore_glib_shutdown(); _ecore_job_shutdown(); _ecore_thread_shutdown(); + _ecore_device_cleanup(); /* this looks horrible - a hack for now, but something to note. as * we delete the _thread_call pipe a thread COULD be doing @@ -751,6 +752,10 @@ _ecore_magic_string_get(Ecore_Magic m) return "Ecore_Event (Event)"; break; + case ECORE_MAGIC_DEV: + return "Ecore_Device (Device)"; + break; + default: return ""; } diff --git a/src/lib/ecore/ecore_device.c b/src/lib/ecore/ecore_device.c new file mode 100644 index 0000000..9362b28 --- /dev/null +++ b/src/lib/ecore/ecore_device.c @@ -0,0 +1,190 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#include "Ecore.h" +#include "ecore_private.h" + +/** + * @struct _Ecore_Device + * Contains information about a device. + */ +struct _Ecore_Device + { + ECORE_MAGIC; /**< ecore magic data */ + const char *name; /**< name of device */ + const char *desc; /**< description of device */ + const char *identifier; /**< identifier of device */ + Ecore_Device_Class clas; /**name), name); +} + +EAPI const char * +ecore_device_name_get(const Ecore_Device *dev) +{ + if (!ECORE_MAGIC_CHECK(dev, ECORE_MAGIC_DEV)) + { + ECORE_MAGIC_FAIL(dev, ECORE_MAGIC_DEV, "ecore_device_name_get"); + return NULL; + } + return dev->name; +} + +EAPI void +ecore_device_description_set(Ecore_Device *dev, const char *desc) +{ + if (!ECORE_MAGIC_CHECK(dev, ECORE_MAGIC_DEV)) + { + ECORE_MAGIC_FAIL(dev, ECORE_MAGIC_DEV, "ecore_device_description_set"); + return; + } + eina_stringshare_replace(&(dev->desc), desc); +} + +EAPI const char * +ecore_device_description_get(const Ecore_Device *dev) +{ + if (!ECORE_MAGIC_CHECK(dev, ECORE_MAGIC_DEV)) + { + ECORE_MAGIC_FAIL(dev, ECORE_MAGIC_DEV, "ecore_device_description_get"); + return NULL; + } + return dev->desc; +} + +EAPI void +ecore_device_identifier_set(Ecore_Device *dev, const char *identifier) +{ + if (!ECORE_MAGIC_CHECK(dev, ECORE_MAGIC_DEV)) + { + ECORE_MAGIC_FAIL(dev, ECORE_MAGIC_DEV, "ecore_device_identifier_set"); + return; + } + eina_stringshare_replace(&(dev->identifier), identifier); +} + +EAPI const char * +ecore_device_identifier_get(const Ecore_Device *dev) +{ + if (!ECORE_MAGIC_CHECK(dev, ECORE_MAGIC_DEV)) + { + ECORE_MAGIC_FAIL(dev, ECORE_MAGIC_DEV, "ecore_device_identifier_get"); + return NULL; + } + return dev->identifier; +} + +EAPI void +ecore_device_class_set(Ecore_Device *dev, Ecore_Device_Class clas) +{ + if (!ECORE_MAGIC_CHECK(dev, ECORE_MAGIC_DEV)) + { + ECORE_MAGIC_FAIL(dev, ECORE_MAGIC_DEV, "ecore_device_class_set"); + return; + } + dev->clas = clas; +} + +EAPI Ecore_Device_Class +ecore_device_class_get(const Ecore_Device *dev) +{ + if (!ECORE_MAGIC_CHECK(dev, ECORE_MAGIC_DEV)) + { + ECORE_MAGIC_FAIL(dev, ECORE_MAGIC_DEV, "ecore_device_class_get"); + return ECORE_DEVICE_CLASS_NONE; + } + return dev->clas; +} + +EAPI void +ecore_device_subclass_set(Ecore_Device *dev, Ecore_Device_Subclass subclas) +{ + if (!ECORE_MAGIC_CHECK(dev, ECORE_MAGIC_DEV)) + { + ECORE_MAGIC_FAIL(dev, ECORE_MAGIC_DEV, "ecore_device_class_set"); + return; + } + dev->subclas = subclas; +} + +EAPI Ecore_Device_Subclass +ecore_device_subclass_get(const Ecore_Device *dev) +{ + if (!ECORE_MAGIC_CHECK(dev, ECORE_MAGIC_DEV)) + { + ECORE_MAGIC_FAIL(dev, ECORE_MAGIC_DEV, "ecore_device_class_get"); + return ECORE_DEVICE_CLASS_NONE; + } + return dev->subclas; +} + +void +_ecore_device_cleanup(void) +{ + Ecore_Device *dev = NULL; + Eina_List *l1, *l2; + + EINA_LIST_FOREACH_SAFE(_ecore_devices, l1, l2, dev) + _ecore_device_free(dev); +} + +void _ecore_device_free(Ecore_Device *dev) +{ + _ecore_devices = eina_list_remove(_ecore_devices, dev); + if (dev->name) eina_stringshare_del(dev->name); + if (dev->desc) eina_stringshare_del(dev->desc); + if (dev->identifier) eina_stringshare_del(dev->identifier); + ECORE_MAGIC_SET(dev, 0); + free(dev); + devices_num--; +} diff --git a/src/lib/ecore/ecore_private.h b/src/lib/ecore/ecore_private.h index a8676a2..8262ede 100644 --- a/src/lib/ecore/ecore_private.h +++ b/src/lib/ecore/ecore_private.h @@ -104,6 +104,7 @@ extern int _ecore_log_dom; #define ECORE_MAGIC_PIPE 0xf7458226 #define ECORE_MAGIC_WIN32_HANDLER 0xf7e8f1a3 #define ECORE_MAGIC_JOB 0x76543210 +#define ECORE_MAGIC_DEV 0x5e9e6510 typedef unsigned int Ecore_Magic; #define ECORE_MAGIC Ecore_Magic __magic @@ -264,6 +265,8 @@ void _ecore_glib_shutdown(void); void _ecore_job_init(void); void _ecore_job_shutdown(void); +void _ecore_device_cleanup(void); + void _ecore_main_loop_init(void); void _ecore_main_loop_shutdown(void); @@ -434,6 +437,7 @@ void ecore_mempool_shutdown(void); GENERIC_ALLOC_FREE_HEADER(Ecore_Event_Handler, ecore_event_handler); GENERIC_ALLOC_FREE_HEADER(Ecore_Event_Filter, ecore_event_filter); GENERIC_ALLOC_FREE_HEADER(Ecore_Event, ecore_event); +//GENERIC_ALLOC_FREE_HEADER(Ecore_Device, ecore_device); //GENERIC_ALLOC_FREE_HEADER(Ecore_Idle_Exiter, ecore_idle_exiter); //GENERIC_ALLOC_FREE_HEADER(Ecore_Idle_Enterer, ecore_idle_enterer); //GENERIC_ALLOC_FREE_HEADER(Ecore_Idler, ecore_idler); diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index 690bc92..e3b8f38 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -121,7 +121,7 @@ struct _Ecore_Drm_Device struct xkb_context *xkb_ctx; - unsigned int window; + int window; Eeze_Udev_Watch *watch; @@ -1035,6 +1035,7 @@ EAPI const char *ecore_drm_evdev_sysname_get(Ecore_Drm_Evdev *evdev); EAPI Eina_Bool ecore_drm_evdev_key_remap_enable(Ecore_Drm_Evdev *edev, Eina_Bool enable); EAPI Eina_Bool ecore_drm_evdev_key_remap_set(Ecore_Drm_Evdev *edev, int *from_keys, int *to_keys, int num); EAPI int ecore_drm_evdev_wheel_click_angle_get(Ecore_Drm_Evdev *dev); +EAPI Ecore_Device *ecore_drm_evdev_get_ecore_device(const char *path, Ecore_Device_Class clas); typedef void (*Ecore_Drm_VBlank_Cb)(void *data); EAPI Eina_Bool ecore_drm_output_wait_vblank(Ecore_Drm_Output *output, int interval, Ecore_Drm_VBlank_Cb func, void *data); diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c index 48f8a68..5860ab0 100644 --- a/src/lib/ecore_drm/ecore_drm_device.c +++ b/src/lib/ecore_drm/ecore_drm_device.c @@ -575,7 +575,7 @@ ecore_drm_device_window_set(Ecore_Drm_Device *dev, unsigned int window) EINA_LIST_FOREACH(dev->seats, l , seat) { EINA_LIST_FOREACH(seat->devices, ll, edev) - _ecore_drm_device_info_send(window, edev, EINA_TRUE); + _ecore_drm_device_add(window, edev); } } diff --git a/src/lib/ecore_drm/ecore_drm_evdev.c b/src/lib/ecore_drm/ecore_drm_evdev.c index 563ce79..b922539 100644 --- a/src/lib/ecore_drm/ecore_drm_evdev.c +++ b/src/lib/ecore_drm/ecore_drm_evdev.c @@ -263,6 +263,29 @@ _device_remapped_key_get(Ecore_Drm_Evdev *edev, int code) return code; } +EAPI Ecore_Device * +ecore_drm_evdev_get_ecore_device(const char *path, Ecore_Device_Class clas) +{ + const Eina_List *dev_list = NULL; + const Eina_List *l; + Ecore_Device *dev = NULL; + const char *identifier; + + if (!path) return NULL; + + dev_list = ecore_device_list(); + if (!dev_list) return NULL; + EINA_LIST_FOREACH(dev_list, l, dev) + { + if (!dev) continue; + identifier = ecore_device_identifier_get(dev); + if (!identifier) continue; + if ((ecore_device_class_get(dev) == clas) && !(strcmp(identifier, path))) + return dev; + } + return NULL; +} + static void _device_handle_key(struct libinput_device *device, struct libinput_event_keyboard *event) { @@ -377,7 +400,7 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar _device_modifiers_update(edev); e->modifiers = edev->xkb.modifiers; - e->dev_name = eina_stringshare_add(edev->path); + e->dev = ecore_drm_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_KEYBOARD); if (state) ecore_event_add(ECORE_EVENT_KEY_DOWN, e, NULL, NULL); @@ -435,7 +458,7 @@ _device_pointer_motion(Ecore_Drm_Evdev *edev, struct libinput_event_pointer *eve ev->multi.y = ev->y; ev->multi.root.x = ev->x; ev->multi.root.y = ev->y; - ev->dev_name = eina_stringshare_add(edev->path); + ev->dev = ecore_drm_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE); ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL); } @@ -573,7 +596,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_name = eina_stringshare_add(edev->path); + ev->dev = ecore_drm_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE); if (state) { @@ -661,7 +684,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_name = eina_stringshare_add(edev->path); + ev->dev = ecore_drm_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE); #if LIBINPUT_HIGHER_08 axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL; @@ -812,7 +835,7 @@ _device_handle_touch_event_send(Ecore_Drm_Evdev *edev, struct libinput_event_tou ev->multi.y = ev->y; ev->multi.root.x = ev->x; ev->multi.root.y = ev->y; - ev->dev_name = eina_stringshare_add(edev->path); + ev->dev = ecore_drm_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH); if (state == ECORE_EVENT_MOUSE_BUTTON_DOWN) { @@ -898,7 +921,7 @@ _device_handle_touch_motion_send(Ecore_Drm_Evdev *edev, struct libinput_event_to ev->multi.y = ev->y; ev->multi.root.x = ev->x; ev->multi.root.y = ev->y; - ev->dev_name = eina_stringshare_add(edev->path); + ev->dev = ecore_drm_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH); ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL); } diff --git a/src/lib/ecore_drm/ecore_drm_inputs.c b/src/lib/ecore_drm/ecore_drm_inputs.c index 2d7b89e..54f781f 100644 --- a/src/lib/ecore_drm/ecore_drm_inputs.c +++ b/src/lib/ecore_drm/ecore_drm_inputs.c @@ -123,8 +123,25 @@ _ecore_event_device_info_free(void *data EINA_UNUSED, void *ev) free(e); } +static Ecore_Device_Class +_ecore_drm_seat_cap_to_ecore_device_class(unsigned int cap) +{ + switch(cap) + { + case EVDEV_SEAT_POINTER: + return ECORE_DEVICE_CLASS_MOUSE; + case EVDEV_SEAT_KEYBOARD: + return ECORE_DEVICE_CLASS_KEYBOARD; + case EVDEV_SEAT_TOUCH: + return ECORE_DEVICE_CLASS_TOUCH; + default: + return ECORE_DEVICE_CLASS_NONE; + } + return ECORE_DEVICE_CLASS_NONE; +} + void -_ecore_drm_device_info_send(unsigned int window, Ecore_Drm_Evdev *edev, Eina_Bool flag) +_ecore_drm_device_info_send(unsigned int window, Ecore_Drm_Evdev *edev, Ecore_Device_Class clas, Eina_Bool flag) { Ecore_Event_Device_Info *e; @@ -133,7 +150,7 @@ _ecore_drm_device_info_send(unsigned int window, Ecore_Drm_Evdev *edev, Eina_Boo e->name = eina_stringshare_add(libinput_device_get_name(edev->device)); e->identifier = eina_stringshare_add(edev->path); e->seatname = eina_stringshare_add(edev->seat->name); - e->caps = edev->seat_caps; + e->clas = clas; e->window = window; if (flag) @@ -142,6 +159,116 @@ _ecore_drm_device_info_send(unsigned int window, Ecore_Drm_Evdev *edev, Eina_Boo ecore_event_add(ECORE_EVENT_DEVICE_DEL, e, _ecore_event_device_info_free, NULL); } +static Eina_Bool +_ecore_drm_device_add_ecore_device(Ecore_Drm_Evdev *edev, Ecore_Device_Class clas) +{ + const Eina_List *dev_list = NULL; + const Eina_List *l; + Ecore_Device *dev = NULL; + const char *identifier; + + if (!edev->path) return EINA_FALSE; + + dev_list = ecore_device_list(); + if (dev_list) + { + EINA_LIST_FOREACH(dev_list, l, dev) + { + if (!dev) continue; + identifier = ecore_device_identifier_get(dev); + if (!identifier) continue; + if ((ecore_device_class_get(dev) == clas) && (!strcmp(identifier, edev->path))) + return EINA_FALSE; + } + } + + if(!(dev = ecore_device_add())) return EINA_FALSE; + + ecore_device_name_set(dev, libinput_device_get_name(edev->device)); + ecore_device_description_set(dev, libinput_device_get_name(edev->device)); + ecore_device_identifier_set(dev, edev->path); + ecore_device_class_set(dev, clas); + return EINA_TRUE; +} + +static Eina_Bool +_ecore_drm_device_del_ecore_device(Ecore_Drm_Evdev *edev, Ecore_Device_Class clas) +{ + const Eina_List *dev_list = NULL; + const Eina_List *l; + Ecore_Device *dev = NULL; + const char *identifier; + + if (!edev->path) return EINA_FALSE; + + dev_list = ecore_device_list(); + if (!dev_list) return EINA_FALSE; + EINA_LIST_FOREACH(dev_list, l, dev) + { + if (!dev) continue; + identifier = ecore_device_identifier_get(dev); + if (!identifier) continue; + if ((ecore_device_class_get(dev) == clas) && (!strcmp(identifier, edev->path))) + { + ecore_device_del(dev); + return EINA_TRUE; + } + } + return EINA_FALSE; +} + +void +_ecore_drm_device_add(unsigned int window, Ecore_Drm_Evdev *edev) +{ + Eina_Bool ret = EINA_FALSE; + Ecore_Device_Class clas; + + if (edev->seat_caps & EVDEV_SEAT_POINTER) + { + clas = _ecore_drm_seat_cap_to_ecore_device_class(EVDEV_SEAT_POINTER); + ret = _ecore_drm_device_add_ecore_device(edev, clas); + if (ret) _ecore_drm_device_info_send(window, edev, clas, 1); + } + if (edev->seat_caps & EVDEV_SEAT_KEYBOARD) + { + clas = _ecore_drm_seat_cap_to_ecore_device_class(EVDEV_SEAT_KEYBOARD); + ret = _ecore_drm_device_add_ecore_device(edev, clas); + if (ret) _ecore_drm_device_info_send(window, edev, clas, 1); + } + if (edev->seat_caps & EVDEV_SEAT_TOUCH) + { + clas = _ecore_drm_seat_cap_to_ecore_device_class(EVDEV_SEAT_TOUCH); + ret = _ecore_drm_device_add_ecore_device(edev, clas); + if (ret) _ecore_drm_device_info_send(window, edev, clas, 1); + } +} + +void +_ecore_drm_device_remove(unsigned int window, Ecore_Drm_Evdev *edev) +{ + Eina_Bool ret = EINA_FALSE; + Ecore_Device_Class clas; + + if (edev->seat_caps & EVDEV_SEAT_POINTER) + { + clas = _ecore_drm_seat_cap_to_ecore_device_class(EVDEV_SEAT_POINTER); + ret = _ecore_drm_device_del_ecore_device(edev, clas); + if (ret) _ecore_drm_device_info_send(window, edev, clas, 0); + } + if (edev->seat_caps & EVDEV_SEAT_KEYBOARD) + { + clas = _ecore_drm_seat_cap_to_ecore_device_class(EVDEV_SEAT_KEYBOARD); + ret = _ecore_drm_device_del_ecore_device(edev, clas); + if (ret) _ecore_drm_device_info_send(window, edev, clas, 0); + } + if (edev->seat_caps & EVDEV_SEAT_TOUCH) + { + clas = _ecore_drm_seat_cap_to_ecore_device_class(EVDEV_SEAT_TOUCH); + ret = _ecore_drm_device_del_ecore_device(edev, clas); + if (ret) _ecore_drm_device_info_send(window, edev, clas, 0); + } +} + static void _device_added(Ecore_Drm_Input *input, struct libinput_device *device) { @@ -195,7 +322,7 @@ _device_added(Ecore_Drm_Input *input, struct libinput_device *device) NULL); if (input->dev->window != -1) // window id is valid - _ecore_drm_device_info_send(input->dev->window, edev, EINA_TRUE); + _ecore_drm_device_add(input->dev->window, edev); TRACE_INPUT_END(); } @@ -233,7 +360,7 @@ _device_removed(Ecore_Drm_Input *input, struct libinput_device *device) NULL); if (input->dev->window != -1) // window id is valid - _ecore_drm_device_info_send(input->dev->window, edev, EINA_FALSE); + _ecore_drm_device_remove(input->dev->window, edev); /* remove this evdev from the seat's list of devices */ edev->seat->devices = eina_list_remove(edev->seat->devices, edev); diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h index 6b8eaba..bc5ffc3 100755 --- a/src/lib/ecore_drm/ecore_drm_private.h +++ b/src/lib/ecore_drm/ecore_drm_private.h @@ -352,7 +352,7 @@ void _ecore_drm_dbus_device_release(uint32_t major, uint32_t minor); Eina_Bool _ecore_drm_dbus_session_take(void); Eina_Bool _ecore_drm_dbus_session_release(void); -void _ecore_drm_device_info_send(unsigned int window, Ecore_Drm_Evdev *edev, Eina_Bool flag); +void _ecore_drm_device_add(unsigned int window, Ecore_Drm_Evdev *edev); void _ecore_drm_inputs_init(void); void _ecore_drm_inputs_shutdown(void); diff --git a/src/lib/ecore_input/Ecore_Input.h b/src/lib/ecore_input/Ecore_Input.h index c7482ab..5acf5b8 100644 --- a/src/lib/ecore_input/Ecore_Input.h +++ b/src/lib/ecore_input/Ecore_Input.h @@ -137,6 +137,22 @@ extern "C" { ECORE_COMPOSE_DONE } Ecore_Compose_State; + typedef enum _Ecore_Device_Type + { + ECORE_DEVICE_POINTER = (1 << 0), + ECORE_DEVICE_KEYBOARD = (1 << 1), + ECORE_DEVICE_TOUCH = (1 << 2), + } Ecore_Device_Type; + + struct _Ecore_Event_Device_Info + { + Ecore_Window window; + const char *name; + const char *identifier; + const char *seatname; + Ecore_Device_Class clas; + }; + /** * @struct _Ecore_Event_Key * Contains information about an Ecore keyboard event. @@ -150,7 +166,7 @@ extern "C" { Ecore_Window window; /**< The main window where event happened */ Ecore_Window root_window; /**< The root window where event happened */ Ecore_Window event_window; /**< The child window where event happened */ - const char *dev_name; /**event_window); if (!lookup) return ECORE_CALLBACK_PASS_ON; - Evas_Device *dev = _ecore_event_get_evas_device(lookup->evas, e->dev_name, EVAS_DEVICE_CLASS_KEYBOARD); + dev = _ecore_event_get_evas_device(lookup->evas, e->dev); if (dev) evas_device_push(lookup->evas, dev); ecore_event_evas_modifier_lock_update(lookup->evas, e->modifiers); @@ -479,6 +481,7 @@ _ecore_event_evas_mouse_button(Ecore_Event_Mouse_Button *e, Ecore_Event_Press pr Ecore_Event_Last *eel; Ecore_Input_Window *lookup; Evas_Button_Flags flags = EVAS_BUTTON_NONE; + Evas_Device *dev; lookup = _ecore_event_window_match(e->event_window); if (!lookup) return ECORE_CALLBACK_PASS_ON; @@ -520,9 +523,7 @@ _ecore_event_evas_mouse_button(Ecore_Event_Mouse_Button *e, Ecore_Event_Press pr } } - Evas_Device *dev = _ecore_event_get_evas_device(lookup->evas, e->dev_name, EVAS_DEVICE_CLASS_MOUSE); - if (!dev) - dev = _ecore_event_get_evas_device(lookup->evas, e->dev_name, EVAS_DEVICE_CLASS_TOUCH); + dev = _ecore_event_get_evas_device(lookup->evas, e->dev); if (dev) evas_device_push(lookup->evas, dev); if (e->multi.device == 0) @@ -585,14 +586,13 @@ ecore_event_evas_mouse_move(void *data EINA_UNUSED, int type EINA_UNUSED, void * { Ecore_Event_Mouse_Move *e; Ecore_Input_Window *lookup; + Evas_Device *dev; e = event; lookup = _ecore_event_window_match(e->event_window); if (!lookup) return ECORE_CALLBACK_PASS_ON; - Evas_Device *dev = _ecore_event_get_evas_device(lookup->evas, e->dev_name, EVAS_DEVICE_CLASS_MOUSE); - if (!dev) - dev = _ecore_event_get_evas_device(lookup->evas, e->dev_name, EVAS_DEVICE_CLASS_TOUCH); + dev = _ecore_event_get_evas_device(lookup->evas, e->dev); if (dev) evas_device_push(lookup->evas, dev); if (e->multi.device == 0) @@ -622,7 +622,7 @@ ecore_event_evas_mouse_move(void *data EINA_UNUSED, int type EINA_UNUSED, void * e->multi.x, e->multi.y, e->timestamp, NULL); } - evas_device_pop(lookup->evas); + evas_device_pop(lookup->evas); return ECORE_CALLBACK_PASS_ON; } @@ -650,12 +650,11 @@ static Eina_Bool _ecore_event_evas_mouse_io(Ecore_Event_Mouse_IO *e, Ecore_Event_IO io) { Ecore_Input_Window *lookup; + Evas_Device *dev; lookup = _ecore_event_window_match(e->event_window); if (!lookup) return ECORE_CALLBACK_PASS_ON; - Evas_Device *dev = _ecore_event_get_evas_device(lookup->evas, e->dev_name, EVAS_DEVICE_CLASS_MOUSE); - if (!dev) - dev = _ecore_event_get_evas_device(lookup->evas, e->dev_name, EVAS_DEVICE_CLASS_TOUCH); + dev = _ecore_event_get_evas_device(lookup->evas, e->dev); if (dev) evas_device_push(lookup->evas, dev); ecore_event_evas_modifier_lock_update(lookup->evas, e->modifiers); @@ -693,13 +692,12 @@ ecore_event_evas_mouse_wheel(void *data EINA_UNUSED, int type EINA_UNUSED, void { Ecore_Event_Mouse_Wheel *e; Ecore_Input_Window *lookup; + Evas_Device *dev; e = event; lookup = _ecore_event_window_match(e->event_window); if (!lookup) return ECORE_CALLBACK_PASS_ON; - Evas_Device *dev = _ecore_event_get_evas_device(lookup->evas, e->dev_name, EVAS_DEVICE_CLASS_MOUSE); - if (!dev) - dev = _ecore_event_get_evas_device(lookup->evas, e->dev_name, EVAS_DEVICE_CLASS_TOUCH); + dev = _ecore_event_get_evas_device(lookup->evas, e->dev); if (dev) evas_device_push(lookup->evas, dev); ecore_event_evas_modifier_lock_update(lookup->evas, e->modifiers); @@ -735,29 +733,13 @@ ecore_event_evas_axis_update(void *data EINA_UNUSED, int type EINA_UNUSED, void return ECORE_CALLBACK_PASS_ON; } -static short -_ecore_event_device_cap_to_class(int cap) -{ - switch(cap) - { - case ECORE_DEVICE_POINTER: - return EVAS_DEVICE_CLASS_MOUSE; - case ECORE_DEVICE_KEYBOARD: - return EVAS_DEVICE_CLASS_KEYBOARD; - case ECORE_DEVICE_TOUCH: - return EVAS_DEVICE_CLASS_TOUCH; - default: - return EVAS_DEVICE_CLASS_NONE; - } - return EVAS_DEVICE_CLASS_NONE; -} - static void -_ecore_event_evas_add_evas_device(Evas *e, const char *name, const char *identifier, Evas_Device_Class clas) +_ecore_event_evas_add_evas_device(Evas *e, const char *name, const char *identifier, Ecore_Device_Class clas) { const Eina_List *dev_list = NULL; const Eina_List *l; Evas_Device *edev = NULL; + const char *edev_name; dev_list = evas_device_list(e, NULL); if (dev_list) @@ -765,8 +747,9 @@ _ecore_event_evas_add_evas_device(Evas *e, const char *name, const char *identif EINA_LIST_FOREACH(dev_list, l, edev) { if (!edev) continue; - if ((evas_device_class_get(edev) == clas) && - !(strcmp(evas_device_description_get(edev), identifier))) + edev_name = evas_device_description_get(edev); + if (!edev_name) continue; + if ((evas_device_class_get(edev) == (Evas_Device_Class)clas) && (!strcmp(edev_name, identifier))) return; } } @@ -779,15 +762,16 @@ _ecore_event_evas_add_evas_device(Evas *e, const char *name, const char *identif } evas_device_name_set(edev, name); evas_device_description_set(edev, identifier); - evas_device_class_set(edev, clas); + evas_device_class_set(edev, (Evas_Device_Class)clas); } static void -_ecore_event_evas_del_evas_device(Evas *e, const char *name, const char *identifier, Evas_Device_Class clas) +_ecore_event_evas_del_evas_device(Evas *e, const char *name, const char *identifier, Ecore_Device_Class clas) { const Eina_List *dev_list = NULL; const Eina_List *l; Evas_Device *edev = NULL; + const char *edev_name; dev_list = evas_device_list(e, NULL); if (!dev_list) @@ -798,9 +782,9 @@ _ecore_event_evas_del_evas_device(Evas *e, const char *name, const char *identif EINA_LIST_FOREACH(dev_list, l, edev) { if (!edev) continue; - if ((evas_device_class_get(edev) == clas) && - !(strcmp(evas_device_description_get(edev), identifier)) && - !(strcmp(evas_device_name_get(edev), name))) + edev_name = evas_device_description_get(edev); + if (!edev_name) continue; + if ((evas_device_class_get(edev) == (Evas_Device_Class)clas) && (!strcmp(edev_name, identifier))) { evas_device_del(edev); return; @@ -808,36 +792,6 @@ _ecore_event_evas_del_evas_device(Evas *e, const char *name, const char *identif } } -static void -_ecore_event_add_del_evas_devices(Evas *e, const char *name, const char *identifier, int caps, Eina_Bool flag) -{ - Evas_Device_Class clas = EVAS_DEVICE_CLASS_NONE; - if (caps & ECORE_DEVICE_POINTER) - { - clas = _ecore_event_device_cap_to_class(ECORE_DEVICE_POINTER); - if (flag) - _ecore_event_evas_add_evas_device(e, name, identifier, clas); - else - _ecore_event_evas_del_evas_device(e, name, identifier, clas); - } - if (caps & ECORE_DEVICE_KEYBOARD) - { - clas = _ecore_event_device_cap_to_class(ECORE_DEVICE_KEYBOARD); - if (flag) - _ecore_event_evas_add_evas_device(e, name, identifier, clas); - else - _ecore_event_evas_del_evas_device(e, name, identifier, clas); - } - if (caps & ECORE_DEVICE_TOUCH) - { - clas = _ecore_event_device_cap_to_class(ECORE_DEVICE_TOUCH); - if (flag) - _ecore_event_evas_add_evas_device(e, name, identifier, clas); - else - _ecore_event_evas_del_evas_device(e, name, identifier, clas); - } -} - EAPI Eina_Bool ecore_event_evas_device_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { @@ -849,7 +803,7 @@ ecore_event_evas_device_add(void *data EINA_UNUSED, int type EINA_UNUSED, void * lookup = _ecore_event_window_match(e->window); if (!lookup) return ECORE_CALLBACK_PASS_ON; - _ecore_event_add_del_evas_devices(lookup->evas, e->name, e->identifier, e->caps, EINA_TRUE); + _ecore_event_evas_add_evas_device(lookup->evas, e->name, e->identifier, e->clas); return ECORE_CALLBACK_PASS_ON; } @@ -865,7 +819,7 @@ ecore_event_evas_device_del(void *data EINA_UNUSED, int type EINA_UNUSED, void * lookup = _ecore_event_window_match(e->window); if (!lookup) return ECORE_CALLBACK_PASS_ON; - _ecore_event_add_del_evas_devices(lookup->evas, e->name, e->identifier, e->caps, EINA_FALSE); + _ecore_event_evas_del_evas_device(lookup->evas, e->name, e->identifier, e->clas); return ECORE_CALLBACK_PASS_ON; } diff --git a/src/lib/ecore_wayland/ecore_wl_input.c b/src/lib/ecore_wayland/ecore_wl_input.c index 0c7a06f..6baff5a 100644 --- a/src/lib/ecore_wayland/ecore_wl_input.c +++ b/src/lib/ecore_wayland/ecore_wl_input.c @@ -93,6 +93,7 @@ static void _ecore_wl_input_mouse_wheel_send(Ecore_Wl_Input *input, unsigned int static Ecore_Wl_Mouse_Down_Info *_ecore_wl_mouse_down_info_get(int dev); static void _ecore_wl_input_device_manager_cb_device_add(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, unsigned int serial EINA_UNUSED, const char *identifier, struct tizen_input_device *device, struct wl_seat *seat); static void _ecore_wl_input_device_manager_cb_device_remove(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, unsigned int serial EINA_UNUSED, const char *identifier, struct tizen_input_device *device, struct wl_seat *seat); +static Ecore_Device *_ecore_wl_input_get_ecore_device(const char *name, Ecore_Device_Class clas); static void _ecore_wl_input_device_cb_device_info(void *data, struct tizen_input_device *tizen_input_device EINA_UNUSED, const char *name, uint32_t clas, uint32_t subclas, struct wl_array *axes EINA_UNUSED); static void _ecore_wl_input_device_cb_event_device(void *data, struct tizen_input_device *tizen_input_device EINA_UNUSED, unsigned int serial EINA_UNUSED, const char *name EINA_UNUSED, uint32_t time EINA_UNUSED); static void _ecore_wl_input_device_cb_axis(void *data EINA_UNUSED, struct tizen_input_device *tizen_input_device EINA_UNUSED, uint32_t axis_type EINA_UNUSED, wl_fixed_t value EINA_UNUSED); @@ -996,7 +997,7 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UN e->timestamp = timestamp; e->modifiers = input->modifiers; e->keycode = code; - e->dev_name = input->last_device_name; + e->dev = _ecore_wl_input_get_ecore_device(input->last_device_name, ECORE_DEVICE_CLASS_KEYBOARD); if (state) ecore_event_add(ECORE_EVENT_KEY_DOWN, e, NULL, NULL); @@ -1490,7 +1491,7 @@ _ecore_wl_input_mouse_move_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, uns ev->multi.y = input->sy; ev->multi.root.x = input->sx; ev->multi.root.y = input->sy; - ev->dev_name = input->last_device_name; + ev->dev = _ecore_wl_input_get_ecore_device(input->last_device_name, ECORE_DEVICE_CLASS_MOUSE); if ((down_info = _ecore_wl_mouse_down_info_get(device))) { @@ -1510,18 +1511,17 @@ _ecore_wl_input_mouse_move_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, uns static void _ecore_wl_input_mouse_in_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int timestamp) { - Ecore_Wl_Event_Mouse_In *ev; + Ecore_Event_Mouse_IO *ev; LOGFN(__FILE__, __LINE__, __FUNCTION__); - if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Mouse_In)))) return; + if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_IO)))) return; ev->x = input->sx; ev->y = input->sy; - ev->root.x = input->sx; - ev->root.y = input->sy; ev->modifiers = input->modifiers; ev->timestamp = timestamp; + ev->dev = _ecore_wl_input_get_ecore_device(input->last_device_name, ECORE_DEVICE_CLASS_MOUSE); if (win) { @@ -1529,24 +1529,23 @@ _ecore_wl_input_mouse_in_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsig ev->event_window = win->id; } - ecore_event_add(ECORE_WL_EVENT_MOUSE_IN, ev, NULL, NULL); + ecore_event_add(ECORE_EVENT_MOUSE_IN, ev, NULL, NULL); } static void _ecore_wl_input_mouse_out_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int timestamp) { - Ecore_Wl_Event_Mouse_Out *ev; + Ecore_Event_Mouse_IO *ev; LOGFN(__FILE__, __LINE__, __FUNCTION__); - if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Mouse_Out)))) return; + if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_IO)))) return; ev->x = input->sx; ev->y = input->sy; - ev->root.x = input->sx; - ev->root.y = input->sy; ev->modifiers = input->modifiers; ev->timestamp = timestamp; + ev->dev = _ecore_wl_input_get_ecore_device(input->last_device_name, ECORE_DEVICE_CLASS_MOUSE); if (win) { @@ -1554,7 +1553,7 @@ _ecore_wl_input_mouse_out_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsi ev->event_window = win->id; } - ecore_event_add(ECORE_WL_EVENT_MOUSE_OUT, ev, NULL, NULL); + ecore_event_add(ECORE_EVENT_MOUSE_OUT, ev, NULL, NULL); } static void @@ -1684,7 +1683,7 @@ _ecore_wl_input_mouse_down_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, int ev->multi.y = input->sy; ev->multi.root.x = input->sx; ev->multi.root.y = input->sy; - ev->dev_name = input->last_device_name; + ev->dev = _ecore_wl_input_get_ecore_device(input->last_device_name, ECORE_DEVICE_CLASS_MOUSE); if (win) { @@ -1760,7 +1759,8 @@ _ecore_wl_input_mouse_up_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, int d ev->multi.angle = 0.0; ev->multi.root.x = input->sx; ev->multi.root.y = input->sy; - ev->dev_name = input->last_device_name; + ev->dev = _ecore_wl_input_get_ecore_device(input->last_device_name, ECORE_DEVICE_CLASS_MOUSE); + if (device < ECORE_WL_TOUCH_MAX) { input->touch_axis[device].radius_x = 1.0; @@ -1793,7 +1793,7 @@ _ecore_wl_input_mouse_wheel_send(Ecore_Wl_Input *input, unsigned int axis, int v ev->y = input->sy; /* ev->root.x = input->sx; */ /* ev->root.y = input->sy; */ - ev->dev_name = input->last_device_name; + ev->dev = _ecore_wl_input_get_ecore_device(input->last_device_name, ECORE_DEVICE_CLASS_MOUSE); if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) { @@ -1881,8 +1881,25 @@ _ecore_wl_input_device_info_free(void *data EINA_UNUSED, void *ev) free(e); } +static Ecore_Device_Class +_ecore_wl_input_cap_to_ecore_device_class(unsigned int cap) +{ + switch(cap) + { + case ECORE_DEVICE_POINTER: + return ECORE_DEVICE_CLASS_MOUSE; + case ECORE_DEVICE_KEYBOARD: + return ECORE_DEVICE_CLASS_KEYBOARD; + case ECORE_DEVICE_TOUCH: + return ECORE_DEVICE_CLASS_TOUCH; + default: + return ECORE_DEVICE_CLASS_NONE; + } + return ECORE_DEVICE_CLASS_NONE; +} + void -_ecore_wl_input_device_info_send(int win_id, const char *name, const char *identifier, Ecore_Device_Type type, Eina_Bool flag) +_ecore_wl_input_device_info_send(int win_id, const char *name, const char *identifier, Ecore_Device_Class clas, Eina_Bool flag) { Ecore_Event_Device_Info *e; @@ -1891,7 +1908,7 @@ _ecore_wl_input_device_info_send(int win_id, const char *name, const char *iden e->name = eina_stringshare_add(name); e->identifier = eina_stringshare_add(identifier); e->seatname = eina_stringshare_add(name); - e->caps = type; + e->clas = clas; e->window = win_id; if (flag) @@ -1900,13 +1917,95 @@ _ecore_wl_input_device_info_send(int win_id, const char *name, const char *iden ecore_event_add(ECORE_EVENT_DEVICE_DEL, e, _ecore_wl_input_device_info_free, NULL); } +static Ecore_Device * +_ecore_wl_input_get_ecore_device(const char *name, Ecore_Device_Class clas) +{ + const Eina_List *dev_list = NULL; + const Eina_List *l; + Ecore_Device *dev = NULL; + const char *identifier; + + if (!name) return NULL; + + dev_list = ecore_device_list(); + if (!dev_list) return NULL; + EINA_LIST_FOREACH(dev_list, l, dev) + { + if (!dev) continue; + identifier = ecore_device_identifier_get(dev); + if (!identifier) continue; + if ((ecore_device_class_get(dev) == clas) && (!strcmp(identifier, name))) + return dev; + } + return NULL; +} + +static Eina_Bool +_ecore_wl_input_add_ecore_device(const char *name, const char *identifier, Ecore_Device_Class clas) +{ + const Eina_List *dev_list = NULL; + const Eina_List *l; + Ecore_Device *dev; + const char *ecdev_name; + + if (!identifier) return EINA_FALSE; + + dev_list = ecore_device_list(); + if (dev_list) + { + EINA_LIST_FOREACH(dev_list, l, dev) + { + if (!dev) continue; + ecdev_name = ecore_device_identifier_get(dev); + if (!ecdev_name) continue; + if ((ecore_device_class_get(dev) == clas) && (!strcmp(ecdev_name, identifier))) + return EINA_FALSE; + } + } + + if(!(dev = ecore_device_add())) return EINA_FALSE; + + ecore_device_name_set(dev, name); + ecore_device_description_set(dev, name); + ecore_device_identifier_set(dev, identifier); + ecore_device_class_set(dev, clas); + return EINA_TRUE; +} + +static Eina_Bool +_ecore_wl_input_del_ecore_device(const char *name, const char *identifier, Ecore_Device_Class clas) +{ + const Eina_List *dev_list = NULL; + const Eina_List *l; + Ecore_Device *dev = NULL; + const char *ecdev_name; + + if (!identifier) return EINA_FALSE; + + dev_list = ecore_device_list(); + if (!dev_list) return EINA_FALSE; + EINA_LIST_FOREACH(dev_list, l, dev) + { + if (!dev) continue; + ecdev_name = ecore_device_identifier_get(dev); + if (!ecdev_name) continue; + if ((ecore_device_class_get(dev) == clas) && (!strcmp(ecdev_name, identifier))) + { + ecore_device_del(dev); + return EINA_TRUE; + } + } + return EINA_FALSE; +} + void -_ecore_wl_input_device_info_broadcast(const char *name, const char *identifier, Ecore_Device_Type type, Eina_Bool flag) +_ecore_wl_input_device_info_broadcast(const char *name, const char *identifier, Ecore_Device_Class clas, Eina_Bool flag) { Eina_Hash *windows = NULL; Eina_Iterator *itr; Ecore_Wl_Window *win = NULL; void *data; + Eina_Bool ret = EINA_FALSE; windows = _ecore_wl_window_hash_get(); if (!windows) return; @@ -1915,7 +2014,12 @@ _ecore_wl_input_device_info_broadcast(const char *name, const char *identifier, while (eina_iterator_next(itr, &data)) { win = data; - _ecore_wl_input_device_info_send(win->id, name, identifier, type, flag); + if (flag) + ret = _ecore_wl_input_add_ecore_device(name, identifier, clas); + else + ret = _ecore_wl_input_del_ecore_device(name, identifier, clas); + if (ret) + _ecore_wl_input_device_info_send(win->id, name, identifier, clas, flag); } eina_iterator_free(itr); @@ -1960,6 +2064,7 @@ _ecore_wl_input_device_manager_cb_device_remove(void *data EINA_UNUSED, struct t Ecore_Wl_Input *input = _ecore_wl_disp->input; Eina_List *l, *ll; Ecore_Wl_Input_Device *dev; + Ecore_Device_Class clas; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!input) return; @@ -1967,9 +2072,11 @@ _ecore_wl_input_device_manager_cb_device_remove(void *data EINA_UNUSED, struct t EINA_LIST_FOREACH_SAFE(input->devices, l, ll, dev) { + if (!dev->identifier) continue; if ((!strcmp(dev->identifier, identifier)) && (seat == dev->seat) && (device == dev->tz_device)) { - _ecore_wl_input_device_info_broadcast(dev->name, dev->identifier, dev->clas, EINA_FALSE); + clas = _ecore_wl_input_cap_to_ecore_device_class(dev->clas); + _ecore_wl_input_device_info_broadcast(dev->name, dev->identifier, clas, EINA_FALSE); if (dev->tz_device) tizen_input_device_destroy(dev->tz_device); if (dev->name) eina_stringshare_del(dev->name); @@ -1989,14 +2096,15 @@ static void _ecore_wl_input_device_cb_device_info(void *data, struct tizen_input_device *tizen_input_device EINA_UNUSED, const char *name, uint32_t clas, uint32_t subclas, struct wl_array *axes EINA_UNUSED) { Ecore_Wl_Input_Device *dev; + Ecore_Device_Class e_clas; if (!(dev = data)) return; dev->clas = clas; dev->subclas = subclas; dev->name = eina_stringshare_add(name); + e_clas = _ecore_wl_input_cap_to_ecore_device_class(clas); - if (!dev->identifier) return; - _ecore_wl_input_device_info_broadcast(dev->name, dev->identifier, dev->clas, EINA_TRUE); + _ecore_wl_input_device_info_broadcast(dev->name, dev->identifier, e_clas, EINA_TRUE); } static void diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c index bca87d2..7602b9e 100644 --- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c +++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c @@ -82,7 +82,7 @@ static Eina_Bool _ecore_evas_wl_common_cb_mouse_in(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { Ecore_Evas *ee; - Ecore_Wl_Event_Mouse_In *ev; + Ecore_Event_Mouse_IO *ev; LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -93,9 +93,6 @@ _ecore_evas_wl_common_cb_mouse_in(void *data EINA_UNUSED, int type EINA_UNUSED, if (ee->in) return ECORE_CALLBACK_PASS_ON; if (ee->func.fn_mouse_in) ee->func.fn_mouse_in(ee); - ecore_event_evas_modifier_lock_update(ee->evas, ev->modifiers); - evas_event_feed_mouse_in(ee->evas, ev->timestamp, NULL); - _ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp); ee->in = EINA_TRUE; return ECORE_CALLBACK_PASS_ON; } @@ -104,7 +101,7 @@ static Eina_Bool _ecore_evas_wl_common_cb_mouse_out(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { Ecore_Evas *ee; - Ecore_Wl_Event_Mouse_Out *ev; + Ecore_Event_Mouse_IO *ev; LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -115,9 +112,6 @@ _ecore_evas_wl_common_cb_mouse_out(void *data EINA_UNUSED, int type EINA_UNUSED, if (ee->in) { - ecore_event_evas_modifier_lock_update(ee->evas, ev->modifiers); - _ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp); - evas_event_feed_mouse_out(ee->evas, ev->timestamp, NULL); if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee); if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object); ee->in = EINA_FALSE; @@ -549,10 +543,10 @@ _ecore_evas_wl_common_init(void) return _ecore_evas_wl_init_count; _ecore_evas_wl_event_hdls[0] = - ecore_event_handler_add(ECORE_WL_EVENT_MOUSE_IN, + ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, _ecore_evas_wl_common_cb_mouse_in, NULL); _ecore_evas_wl_event_hdls[1] = - ecore_event_handler_add(ECORE_WL_EVENT_MOUSE_OUT, + ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, _ecore_evas_wl_common_cb_mouse_out, NULL); _ecore_evas_wl_event_hdls[2] = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, -- 2.7.4