bdilly pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=7aab35961fcd4a8cb93126ec38bf7690b2c5c7d8
commit 7aab35961fcd4a8cb93126ec38bf7690b2c5c7d8 Author: Bruno Dilly <[email protected]> Date: Wed Oct 5 10:36:19 2016 -0300 ecore_wl2: add ecore event for seat capabilities change So when mouse / keyboard are present or not it will generate events. ecore_evas/wayland will handle that creating or deleting evas devices for each one (seat device will be used as parent). --- src/lib/ecore_wl2/Ecore_Wl2.h | 9 +++ src/lib/ecore_wl2/ecore_wl2.c | 3 + src/lib/ecore_wl2/ecore_wl2_input.c | 11 +++ .../engines/wayland/ecore_evas_wayland_common.c | 86 +++++++++++++++++++++- 4 files changed, 108 insertions(+), 1 deletion(-) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 19c9965..be9f68f 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -145,6 +145,14 @@ typedef struct _Ecore_Wl2_Event_Seat_Name unsigned int id; } Ecore_Wl2_Event_Seat_Name; +typedef struct _Ecore_Wl2_Event_Seat_Capabilities +{ + unsigned int id; + Eina_Bool pointer_enabled : 1; + Eina_Bool keyboard_enabled : 1; + Eina_Bool touch_enabled : 1; +} Ecore_Wl2_Event_Seat_Capabilities; + typedef enum { ECORE_WL2_SELECTION_CNP, @@ -210,6 +218,7 @@ EAPI extern int ECORE_WL2_EVENT_WINDOW_CONFIGURE; /** @since 1.17 */ EAPI extern int ECORE_WL2_EVENT_SYNC_DONE; /** @since 1.17 */ EAPI extern int ECORE_WL2_EVENT_OFFER_DATA_READY; /** @since 1.19 */ EAPI extern int ECORE_WL2_EVENT_SEAT_NAME_CHANGED; /** @since 1.19 */ +EAPI extern int ECORE_WL2_EVENT_SEAT_CAPABILITIES_CHANGED; /** @since 1.19 */ /** * @file * @brief Ecore functions for dealing with the Wayland display protocol diff --git a/src/lib/ecore_wl2/ecore_wl2.c b/src/lib/ecore_wl2/ecore_wl2.c index ceb6dce..1855a96 100644 --- a/src/lib/ecore_wl2/ecore_wl2.c +++ b/src/lib/ecore_wl2/ecore_wl2.c @@ -32,6 +32,7 @@ EAPI int ECORE_WL2_EVENT_WINDOW_CONFIGURE = 0; EAPI int ECORE_WL2_EVENT_SYNC_DONE = 0; EAPI int ECORE_WL2_EVENT_OFFER_DATA_READY = 0; EAPI int ECORE_WL2_EVENT_SEAT_NAME_CHANGED = 0; +EAPI int ECORE_WL2_EVENT_SEAT_CAPABILITIES_CHANGED = 0; EAPI int _ecore_wl2_event_window_www = -1; EAPI int _ecore_wl2_event_window_www_drag = -1; @@ -91,6 +92,7 @@ ecore_wl2_init(void) ECORE_WL2_EVENT_SYNC_DONE = ecore_event_type_new(); ECORE_WL2_EVENT_OFFER_DATA_READY = ecore_event_type_new(); ECORE_WL2_EVENT_SEAT_NAME_CHANGED = ecore_event_type_new(); + ECORE_WL2_EVENT_SEAT_CAPABILITIES_CHANGED = ecore_event_type_new(); _ecore_wl2_event_window_www = ecore_event_type_new(); _ecore_wl2_event_window_www_drag = ecore_event_type_new(); } @@ -143,6 +145,7 @@ ecore_wl2_shutdown(void) ECORE_WL2_EVENT_SYNC_DONE = 0; ECORE_WL2_EVENT_OFFER_DATA_READY = 0; ECORE_WL2_EVENT_SEAT_NAME_CHANGED = 0; + ECORE_WL2_EVENT_SEAT_CAPABILITIES_CHANGED = 0; /* shutdown Ecore_Event */ ecore_event_shutdown(); diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c b/src/lib/ecore_wl2/ecore_wl2_input.c index 36013fb..3ce69e4 100644 --- a/src/lib/ecore_wl2/ecore_wl2_input.c +++ b/src/lib/ecore_wl2/ecore_wl2_input.c @@ -1130,6 +1130,7 @@ static const struct wl_data_device_listener _data_listener = static void _seat_cb_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps) { + Ecore_Wl2_Event_Seat_Capabilities *ev; Ecore_Wl2_Input *input; input = data; @@ -1185,6 +1186,16 @@ _seat_cb_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability wl_touch_destroy(input->wl.touch); input->wl.touch = NULL; } + + ev = calloc(1, sizeof(Ecore_Wl2_Event_Seat_Capabilities)); + EINA_SAFETY_ON_NULL_RETURN(ev); + + ev->id = input->id; + ev->pointer_enabled = !!(caps & WL_SEAT_CAPABILITY_POINTER); + ev->keyboard_enabled = !!(caps & WL_SEAT_CAPABILITY_KEYBOARD); + ev->touch_enabled = !!(caps & WL_SEAT_CAPABILITY_TOUCH); + + ecore_event_add(ECORE_WL2_EVENT_SEAT_CAPABILITIES_CHANGED, ev, NULL, NULL); } 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 980531c..697909c 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 @@ -30,6 +30,9 @@ typedef struct _EE_Wl_Device EE_Wl_Device; struct _EE_Wl_Device { Evas_Device *seat; + Evas_Device *pointer; + Evas_Device *keyboard; + Evas_Device *touch; unsigned int id; }; @@ -44,7 +47,7 @@ EVAS_SMART_SUBCLASS_NEW(_smart_frame_type, _ecore_evas_wl_frame, /* local variables */ static int _ecore_evas_wl_init_count = 0; -static Ecore_Event_Handler *_ecore_evas_wl_event_hdls[11]; +static Ecore_Event_Handler *_ecore_evas_wl_event_hdls[12]; static void _ecore_evas_wayland_resize(Ecore_Evas *ee, int location); @@ -494,6 +497,12 @@ _ecore_evas_wl_common_device_free(EE_Wl_Device *device) { if (device->seat) evas_device_del(device->seat); + if (device->pointer) + evas_device_del(device->pointer); + if (device->keyboard) + evas_device_del(device->keyboard); + if (device->touch) + evas_device_del(device->touch); free(device); } @@ -562,6 +571,77 @@ _ecore_evas_wl_common_cb_seat_name_changed(void *d EINA_UNUSED, int t EINA_UNUSE return ECORE_CALLBACK_PASS_ON; } +static Eina_Bool +_ecore_evas_wl_common_cb_seat_capabilities_changed(void *d EINA_UNUSED, int t EINA_UNUSED, void *event) +{ + Ecore_Wl2_Event_Seat_Capabilities *ev = event; + Ecore_Evas *ee; + Eina_List *l, *ll; + + EINA_LIST_FOREACH(ee_list, l, ee) + { + Ecore_Evas_Engine_Wl_Data *wdata; + EE_Wl_Device *device; + + wdata = ee->engine.data; + + EINA_LIST_FOREACH(wdata->devices_list, ll, device) + { + if (device->id == ev->id) + { + if (ev->pointer_enabled && !device->pointer) + { + device->pointer = evas_device_add_full( + ee->evas, "Mouse", + "A wayland pointer device", + device->seat, NULL, + EVAS_DEVICE_CLASS_MOUSE, + EVAS_DEVICE_SUBCLASS_NONE); + } + else if (!ev->pointer_enabled && device->pointer) + { + evas_device_del(device->pointer); + device->pointer = NULL; + } + + if (ev->keyboard_enabled && !device->keyboard) + { + device->keyboard = evas_device_add_full( + ee->evas, "Keyboard", + "A wayland keyboard device", + device->seat, NULL, + EVAS_DEVICE_CLASS_KEYBOARD, + EVAS_DEVICE_SUBCLASS_NONE); + } + else if (!ev->keyboard_enabled && device->keyboard) + { + evas_device_del(device->keyboard); + device->keyboard = NULL; + } + + if (ev->touch_enabled && !device->touch) + { + device->touch = evas_device_add_full( + ee->evas, "Touch", + "A wayland touch device", + device->seat, NULL, + EVAS_DEVICE_CLASS_TOUCH, + EVAS_DEVICE_SUBCLASS_NONE); + } + else if (!ev->touch_enabled && device->touch) + { + evas_device_del(device->touch); + device->touch = NULL; + } + + break; + } + } + } + + return ECORE_CALLBACK_PASS_ON; +} + int _ecore_evas_wl_common_init(void) { @@ -603,6 +683,10 @@ _ecore_evas_wl_common_init(void) _ecore_evas_wl_event_hdls[10] = ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_NAME_CHANGED, _ecore_evas_wl_common_cb_seat_name_changed, NULL); + _ecore_evas_wl_event_hdls[11] = + ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_CAPABILITIES_CHANGED, + _ecore_evas_wl_common_cb_seat_capabilities_changed, + NULL); ecore_event_evas_init(); --
