return code;
}
-E_API Evas_Device *
-e_input_evdev_get_evas_device(const char *path, Evas_Device_Class clas)
+E_API Ecore_Device *
+e_input_evdev_get_ecore_device(const char *path, Ecore_Device_Class clas)
{
const Eina_List *dev_list = NULL;
const Eina_List *l;
- Evas_Device *dev = NULL;
+ Ecore_Device *dev = NULL;
const char *identifier;
if (!path) return NULL;
- dev_list = evas_device_list(e_comp->evas, NULL);
+ dev_list = ecore_device_list();
if (!dev_list) return NULL;
EINA_LIST_FOREACH(dev_list, l, dev)
{
if (!dev) continue;
- identifier = evas_device_description_get(dev);
+ identifier = ecore_device_identifier_get(dev);
if (!identifier) continue;
- if ((evas_device_class_get(dev) == clas) && !(strcmp(identifier, path)))
+ if ((ecore_device_class_get(dev) == clas) && !(strcmp(identifier, path)))
return dev;
}
return NULL;
}
static void
+_e_input_event_mouse_move_cb_free(void *data EINA_UNUSED, void *event)
+{
+ Ecore_Event_Mouse_Move *ev = event;
+
+ if (ev->dev) ecore_device_unref(ev->dev);
+
+ free(ev);
+}
+
+static void
+_e_input_event_mouse_wheel_cb_free(void *data EINA_UNUSED, void *event)
+{
+ Ecore_Event_Mouse_Wheel *ev = event;
+
+ if (ev->dev) ecore_device_unref(ev->dev);
+
+ free(ev);
+}
+
+static void
+_e_input_event_mouse_button_cb_free(void *data EINA_UNUSED, void *event)
+{
+ Ecore_Event_Mouse_Button *ev = event;
+
+ if (ev->dev) ecore_device_unref(ev->dev);
+
+ free(ev);
+}
+
+static void
+_e_input_event_key_cb_free(void *data EINA_UNUSED, void *event)
+{
+ Ecore_Event_Key *ev = event;
+
+ if (ev->dev) ecore_device_unref(ev->dev);
+
+ free(ev);
+}
+
+static void
_device_handle_key(struct libinput_device *device, struct libinput_event_keyboard *event)
{
E_Input_Evdev *edev;
return;
}
- if (!edev->evas_dev)
- edev->evas_dev = e_input_evdev_get_evas_device(edev->path, EVAS_DEVICE_CLASS_KEYBOARD);
+ if (!edev->ecore_dev)
+ edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_KEYBOARD);
- if (!edev->evas_dev)
+ if (!edev->ecore_dev)
{
- ERR("Failed to get source evas device from event !\n");
+ ERR("Failed to get source ecore device from event !\n");
return;
}
_device_modifiers_update(edev);
e->modifiers = edev->xkb.modifiers;
- e->dev = edev->evas_dev;
+ e->dev = ecore_device_ref(edev->ecore_dev);
if (state)
- ecore_event_add(ECORE_EVENT_KEY_DOWN, e, NULL, NULL);
+ ecore_event_add(ECORE_EVENT_KEY_DOWN, e, _e_input_event_key_cb_free, NULL);
else
- ecore_event_add(ECORE_EVENT_KEY_UP, e, NULL, NULL);
+ ecore_event_add(ECORE_EVENT_KEY_UP, e, _e_input_event_key_cb_free, NULL);
if (tmp) free(tmp);
}
if (!(input = edev->seat->input)) return;
- if (!edev->evas_dev)
- edev->evas_dev = e_input_evdev_get_evas_device(edev->path, EVAS_DEVICE_CLASS_MOUSE);
+ if (!edev->ecore_dev)
+ edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
- if (!edev->evas_dev)
+ if (!edev->ecore_dev)
{
- ERR("Failed to get source evas device from event !\n");
+ ERR("Failed to get source ecore device from event !\n");
return;
}
ev->multi.y = ev->y;
ev->multi.root.x = ev->x;
ev->multi.root.y = ev->y;
- ev->dev = edev->evas_dev;
+ ev->dev = ecore_device_ref(edev->ecore_dev);
- ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
+ ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _e_input_event_mouse_move_cb_free, NULL);
}
void
return;
}
- if (!edev->evas_dev)
- edev->evas_dev = e_input_evdev_get_evas_device(edev->path, EVAS_DEVICE_CLASS_MOUSE);
+ if (!edev->ecore_dev)
+ edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
- if (!edev->evas_dev)
+ if (!edev->ecore_dev)
{
- ERR("Failed to get source evas device from event !\n");
+ ERR("Failed to get source ecore device from event !\n");
return;
}
ev->multi.y = ev->y;
ev->multi.root.x = ev->x;
ev->multi.root.y = ev->y;
- ev->dev = edev->evas_dev;
+ ev->dev = ecore_device_ref(edev->ecore_dev);
if (state)
{
ev->triple_click = 1;
if (state)
- ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL);
+ ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, _e_input_event_mouse_button_cb_free, NULL);
else
- ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
+ ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, _e_input_event_mouse_button_cb_free, NULL);
}
static void
return;
}
- if (!edev->evas_dev)
- edev->evas_dev = e_input_evdev_get_evas_device(edev->path, EVAS_DEVICE_CLASS_MOUSE);
+ if (!edev->ecore_dev)
+ edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
- if (!edev->evas_dev)
+ if (!edev->ecore_dev)
{
- ERR("Failed to get source evas device from event !\n");
+ ERR("Failed to get source ecore device from event !\n");
return;
}
ev->y = edev->seat->ptr.iy;
ev->root.x = ev->x;
ev->root.y = ev->y;
- ev->dev = edev->evas_dev;
+ ev->dev = ecore_device_ref(edev->ecore_dev);
axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
if (libinput_event_pointer_has_axis(event, axis))
ev->z = libinput_event_pointer_get_axis_value(event, axis);
}
- ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL);
+ ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _e_input_event_mouse_wheel_cb_free, NULL);
}
static void
if (!edev) return;
if (!(input = edev->seat->input)) return;
- if (!edev->evas_dev)
- edev->evas_dev = e_input_evdev_get_evas_device(edev->path, EVAS_DEVICE_CLASS_TOUCH);
+ if (!edev->ecore_dev)
+ edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
- if (!edev->evas_dev)
+ if (!edev->ecore_dev)
{
- ERR("Failed to get source evas device from event !\n");
+ ERR("Failed to get source ecore device from event !\n");
return;
}
ev->multi.y = ev->y;
ev->multi.root.x = ev->x;
ev->multi.root.y = ev->y;
- ev->dev = edev->evas_dev;
+ ev->dev = ecore_device_ref(edev->ecore_dev);
if (state == ECORE_EVENT_MOUSE_BUTTON_DOWN)
{
if (edev->mouse.did_triple)
ev->triple_click = 1;
- ecore_event_add(state, ev, NULL, NULL);
+ ecore_event_add(state, ev, _e_input_event_mouse_button_cb_free, NULL);
}
static void
if (!edev) return;
if (!(input = edev->seat->input)) return;
- if (!edev->evas_dev)
- edev->evas_dev = e_input_evdev_get_evas_device(edev->path, EVAS_DEVICE_CLASS_TOUCH);
+ if (!edev->ecore_dev)
+ edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
- if (!edev->evas_dev)
+ if (!edev->ecore_dev)
{
- ERR("Failed to get source evas device from event !\n");
+ ERR("Failed to get source ecore device from event !\n");
return;
}
ev->multi.y = ev->y;
ev->multi.root.x = ev->x;
ev->multi.root.y = ev->y;
- ev->dev = edev->evas_dev;
+ ev->dev = ecore_device_ref(edev->ecore_dev);
- ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
+ ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _e_input_event_mouse_move_cb_free, NULL);
}
static void
_e_input_aux_data_event_free(void *user_data EINA_UNUSED, void *ev)
{
Ecore_Event_Axis_Update *e = (Ecore_Event_Axis_Update *)ev;
- if (e->axis)
- free(e->axis);
+
+ if (e->axis) free(e->axis);
+ if (e->dev) ecore_device_unref(e->dev);
+
free(e);
}
if (!(edev = libinput_device_get_user_data(device))) goto end;
if (!(input = edev->seat->input)) goto end;
- if (!edev->evas_dev)
- edev->evas_dev = e_input_evdev_get_evas_device(edev->path, EVAS_DEVICE_CLASS_MOUSE);
+ if (!edev->ecore_dev)
+ edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
- if (!edev->evas_dev)
+ if (!edev->ecore_dev)
{
- ERR("Failed to get source evas device from event !\n");
+ ERR("Failed to get source ecore device from event !\n");
goto end;
}
ev->naxis = 1;
}
ev->axis = axis;
- ev->dev = edev->evas_dev;
+ ev->dev = ecore_device_ref(edev->ecore_dev);
ecore_event_add(ECORE_EVENT_AXIS_UPDATE, ev, _e_input_aux_data_event_free, NULL);
if (edev->xkb.keymap) xkb_map_unref(edev->xkb.keymap);
}
- if (edev->evas_dev) evas_device_del(edev->evas_dev);
+ if (edev->ecore_dev) ecore_device_del(edev->ecore_dev);
if (edev->path) eina_stringshare_del(edev->path);
if (edev->device) libinput_device_unref(edev->device);
if (edev->key_remap_hash) eina_hash_free(edev->key_remap_hash);
#include "e.h"
#include "e_input_private.h"
-static E_Input_Seat *
-_seat_create(E_Input_Backend *input, const char *seat)
+static Ecore_Device_Class
+_e_input_seat_cap_to_ecore_device_class(unsigned int cap)
{
- E_Input_Seat *s;
- Evas *evs = NULL;
- E_Input *ei = NULL;
- Ecore_Evas *ee = NULL;
- Evas_Device *evas_dev = NULL;
+ switch(cap)
+ {
+ case E_INPUT_SEAT_POINTER:
+ return ECORE_DEVICE_CLASS_MOUSE;
+ case E_INPUT_SEAT_KEYBOARD:
+ return ECORE_DEVICE_CLASS_KEYBOARD;
+ case E_INPUT_SEAT_TOUCH:
+ return ECORE_DEVICE_CLASS_TOUCH;
+ default:
+ return ECORE_DEVICE_CLASS_NONE;
+ }
+ return ECORE_DEVICE_CLASS_NONE;
+}
+
+static void
+_e_input_ecore_device_info_free(void *data EINA_UNUSED, void *ev)
+{
+ Ecore_Event_Device_Info *e;
+
+ e = ev;
+ eina_stringshare_del(e->name);
+ eina_stringshare_del(e->identifier);
+ eina_stringshare_del(e->seatname);
+
+ free(e);
+}
+
+void
+_e_input_ecore_device_event(Ecore_Device *dev, Eina_Bool flag)
+{
+ Ecore_Event_Device_Info *e;
+ E_Input *e_input;
- ei = e_input_get();
- if (!ei) return NULL;
+ if (!(e = calloc(1, sizeof(Ecore_Event_Device_Info)))) return;
- ee = e_input_ecore_evas_get(ei);
- if (!ee) return NULL;
+ e_input = e_input_get();
- evs = ecore_evas_get(ee);
- if (!evs) return NULL;
+ e->window = e_input?e_input->window:(Ecore_Window)0;
+ e->name = eina_stringshare_add(ecore_device_name_get(dev));
+ e->identifier = eina_stringshare_add(ecore_device_identifier_get(dev));
+ e->seatname = eina_stringshare_add(ecore_device_name_get(dev));
+ e->clas = ecore_device_class_get(dev);
+ e->subclas = ecore_device_subclass_get(dev);
+
+ if (flag)
+ ecore_event_add(ECORE_EVENT_DEVICE_ADD, e, _e_input_ecore_device_info_free, NULL);
+ else
+ ecore_event_add(ECORE_EVENT_DEVICE_DEL, e, _e_input_ecore_device_info_free, NULL);
+}
+
+static E_Input_Seat *
+_seat_create(E_Input_Backend *input, const char *seat)
+{
+ E_Input_Seat *s;
+ Ecore_Device *ecore_dev = NULL;
/* create an evas device of a seat */
- evas_dev = evas_device_add_full(evs, seat, "Enlightenment seat", NULL, NULL,
- EVAS_DEVICE_CLASS_SEAT, EVAS_DEVICE_SUBCLASS_NONE);
- if (!evas_dev)
+ ecore_dev = ecore_device_add();
+ if (!ecore_dev)
{
- ERR("Failed to create an evas device for a seat !\n");
+ ERR("Failed to create an ecore device for a seat !\n");
return NULL;
}
+ ecore_device_name_set(ecore_dev, seat);
+ ecore_device_identifier_set(ecore_dev, "Enlightenment seat");
+ ecore_device_class_set(ecore_dev, ECORE_DEVICE_CLASS_SEAT);
+ ecore_device_subclass_set(ecore_dev, ECORE_DEVICE_SUBCLASS_NONE);
+
/* try to allocate space for new seat */
if (!(s = calloc(1, sizeof(E_Input_Seat))))
{
- evas_device_del(evas_dev);
+ ecore_device_del(ecore_dev);
return NULL;
}
s->input = input;
s->name = eina_stringshare_add(seat);
- s->evas_dev = evas_dev;
+ s->ecore_dev = ecore_dev;
/* add this new seat to list */
input->dev->seats = eina_list_append(input->dev->seats, s);
ecore_event_add(E_INPUT_EVENT_SEAT_ADD, NULL, NULL, NULL);
+ _e_input_ecore_device_event(ecore_dev, EINA_TRUE);
+
return s;
}
return _seat_create(input, seat);
}
-static Evas_Device_Class
-_e_input_seat_cap_to_evas_device_class(unsigned int cap)
-{
- switch(cap)
- {
- case E_INPUT_SEAT_POINTER:
- return EVAS_DEVICE_CLASS_MOUSE;
- case E_INPUT_SEAT_KEYBOARD:
- return EVAS_DEVICE_CLASS_KEYBOARD;
- case E_INPUT_SEAT_TOUCH:
- return EVAS_DEVICE_CLASS_TOUCH;
- default:
- return EVAS_DEVICE_CLASS_NONE;
- }
- return EVAS_DEVICE_CLASS_NONE;
-}
static Eina_Bool
-_e_input_add_evas_device(E_Input_Evdev *edev, Evas_Device_Class clas)
+_e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
{
const Eina_List *dev_list = NULL;
const Eina_List *l;
- Evas_Device *dev = NULL;
+ Ecore_Device *dev = NULL;
const char *identifier;
- Ecore_Evas *ee = NULL;
- E_Input *ei = NULL;
- Evas *evs = NULL;
-
if (!edev || !edev->path) return EINA_FALSE;
- dev_list = evas_device_list(e_comp->evas, NULL);
+ dev_list = ecore_device_list();
if (dev_list)
{
EINA_LIST_FOREACH(dev_list, l, dev)
{
if (!dev) continue;
- identifier = evas_device_description_get(dev);
+ identifier = ecore_device_description_get(dev);
if (!identifier) continue;
- if ((evas_device_class_get(dev) == clas) && (!strcmp(identifier, edev->path)))
- return EINA_FALSE;
+ if ((ecore_device_class_get(dev) == clas) && (!strcmp(identifier, edev->path)))
+ return EINA_FALSE;
}
}
- ei = e_input_get();
- if (!ei) return EINA_FALSE;
-
- ee = e_input_ecore_evas_get(ei);
- if (!ee) return EINA_FALSE;
-
- evs = ecore_evas_get(ee);
- if (!evs) return EINA_FALSE;
-
- dev = evas_device_add_full(evs,libinput_device_get_name(edev->device),
- edev->path, edev->seat->evas_dev , NULL, clas, EVAS_DEVICE_SUBCLASS_NONE);
+ dev = ecore_device_add();
if (!dev)
{
- edev->evas_dev = NULL;
+ edev->ecore_dev = NULL;
return EINA_FALSE;
}
- edev->evas_dev = dev;
+ ecore_device_name_set(dev, libinput_device_get_name(edev->device));
+ ecore_device_identifier_set(dev, edev->path);
+ ecore_device_class_set(dev, clas);
+ ecore_device_subclass_set(dev, ECORE_DEVICE_SUBCLASS_NONE);
+
+ edev->ecore_dev = ecore_device_ref(dev);
+
+ _e_input_ecore_device_event(dev, EINA_TRUE);
return EINA_TRUE;
}
static Eina_Bool
-_e_input_remove_evas_device(E_Input_Evdev *edev, Evas_Device_Class clas)
+_e_input_remove_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
{
const Eina_List *dev_list = NULL;
const Eina_List *l;
- Evas_Device *dev = NULL;
+ Ecore_Device *dev = NULL;
const char *identifier;
if (!edev->path) return EINA_FALSE;
- dev_list = evas_device_list(e_comp->evas, NULL);
+ dev_list = ecore_device_list();
if (!dev_list) return EINA_FALSE;
EINA_LIST_FOREACH(dev_list, l, dev)
{
if (!dev) continue;
- identifier = evas_device_description_get(dev);
+ identifier = ecore_device_description_get(dev);
if (!identifier) continue;
- if ((evas_device_class_get(dev) == clas) && (!strcmp(identifier, edev->path)))
+ if ((ecore_device_class_get(dev) == clas) && (!strcmp(identifier, edev->path)))
{
- evas_device_del(dev);
- edev->evas_dev = NULL;
+ ecore_device_del(dev);
+ edev->ecore_dev = NULL;
+ _e_input_ecore_device_event(dev, EINA_FALSE);
return EINA_TRUE;
}
}
_e_input_device_add(E_Input_Evdev *edev)
{
Eina_Bool ret = EINA_FALSE;
- Evas_Device_Class clas;
+ Ecore_Device_Class clas;
if (edev->caps & E_INPUT_SEAT_POINTER)
{
- clas = _e_input_seat_cap_to_evas_device_class(E_INPUT_SEAT_POINTER);
- ret = _e_input_add_evas_device(edev, clas);
+ clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_POINTER);
+ ret = _e_input_add_ecore_device(edev, clas);
}
if (edev->caps & E_INPUT_SEAT_KEYBOARD)
{
- clas = _e_input_seat_cap_to_evas_device_class(E_INPUT_SEAT_KEYBOARD);
- ret = _e_input_add_evas_device(edev, clas);
+ clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_KEYBOARD);
+ ret = _e_input_add_ecore_device(edev, clas);
}
if (edev->caps & E_INPUT_SEAT_TOUCH)
{
- clas = _e_input_seat_cap_to_evas_device_class(E_INPUT_SEAT_TOUCH);
- ret = _e_input_add_evas_device(edev, clas);
+ clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_TOUCH);
+ ret = _e_input_add_ecore_device(edev, clas);
}
return ret;
void
_e_input_device_remove(E_Input_Evdev *edev)
{
- Evas_Device_Class clas;
+ Ecore_Device_Class clas;
if (edev->caps & E_INPUT_SEAT_POINTER)
{
- clas = _e_input_seat_cap_to_evas_device_class(E_INPUT_SEAT_POINTER);
- _e_input_remove_evas_device(edev, clas);
+ clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_POINTER);
+ _e_input_remove_ecore_device(edev, clas);
}
if (edev->caps & E_INPUT_SEAT_KEYBOARD)
{
- clas = _e_input_seat_cap_to_evas_device_class(E_INPUT_SEAT_KEYBOARD);
- _e_input_remove_evas_device(edev, clas);
+ clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_KEYBOARD);
+ _e_input_remove_ecore_device(edev, clas);
}
if (edev->caps & E_INPUT_SEAT_TOUCH)
{
- clas = _e_input_seat_cap_to_evas_device_class(E_INPUT_SEAT_TOUCH);
- _e_input_remove_evas_device(edev, clas);
+ clas = _e_input_seat_cap_to_ecore_device_class(E_INPUT_SEAT_TOUCH);
+ _e_input_remove_ecore_device(edev, clas);
}
}
if (EINA_FALSE == _e_input_device_add(edev))
{
ERR("Failed to create evas device !\n");
- return;
+ return;
}
ev->name = eina_stringshare_add(libinput_device_get_name(device));
ev->sysname = eina_stringshare_add(edev->path);
ev->seatname = eina_stringshare_add(edev->seat->name);
ev->caps = edev->caps;
- ev->clas = evas_device_class_get(edev->evas_dev);
+ ev->clas = ecore_device_class_get(edev->ecore_dev);
ev->identifier = eina_stringshare_add(edev->path);
- ev->subclas = evas_device_subclass_get(edev->evas_dev);
+ ev->subclas = ecore_device_subclass_get(edev->ecore_dev);
ecore_event_add(E_INPUT_EVENT_INPUT_DEVICE_ADD,
ev,
ev->sysname = eina_stringshare_add(edev->path);
ev->seatname = eina_stringshare_add(edev->seat->name);
ev->caps = edev->caps;
- ev->clas = evas_device_class_get(edev->evas_dev);
+ ev->clas = ecore_device_class_get(edev->ecore_dev);
ev->identifier = eina_stringshare_add(edev->path);
- ev->subclas = evas_device_subclass_get(edev->evas_dev);
+ ev->subclas = ecore_device_subclass_get(edev->ecore_dev);
ecore_event_add(E_INPUT_EVENT_INPUT_DEVICE_DEL,
ev,