diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 30fb5d97b5..19c9965ede 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -139,6 +139,12 @@ typedef struct _Ecore_Wl2_Event_Data_Source_Send int fd; } Ecore_Wl2_Event_Data_Source_Send; +typedef struct _Ecore_Wl2_Event_Seat_Name +{ + Eina_Stringshare *name; + unsigned int id; +} Ecore_Wl2_Event_Seat_Name; + typedef enum { ECORE_WL2_SELECTION_CNP, @@ -203,6 +209,7 @@ EAPI extern int ECORE_WL2_EVENT_DATA_SOURCE_SEND; /** @since 1.17 */ 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 */ /** * @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 397f8e3f16..ceb6dce80f 100644 --- a/src/lib/ecore_wl2/ecore_wl2.c +++ b/src/lib/ecore_wl2/ecore_wl2.c @@ -31,6 +31,7 @@ EAPI int ECORE_WL2_EVENT_DATA_SOURCE_SEND = 0; 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_window_www = -1; EAPI int _ecore_wl2_event_window_www_drag = -1; @@ -89,6 +90,7 @@ ecore_wl2_init(void) ECORE_WL2_EVENT_WINDOW_CONFIGURE = ecore_event_type_new(); 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_window_www = ecore_event_type_new(); _ecore_wl2_event_window_www_drag = ecore_event_type_new(); } @@ -140,6 +142,7 @@ ecore_wl2_shutdown(void) ECORE_WL2_EVENT_WINDOW_CONFIGURE = 0; ECORE_WL2_EVENT_SYNC_DONE = 0; ECORE_WL2_EVENT_OFFER_DATA_READY = 0; + ECORE_WL2_EVENT_SEAT_NAME_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 b89e3e1484..36013fba05 100644 --- a/src/lib/ecore_wl2/ecore_wl2_input.c +++ b/src/lib/ecore_wl2/ecore_wl2_input.c @@ -1188,11 +1188,31 @@ _seat_cb_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability } static void -_seat_cb_name(void *data EINA_UNUSED, struct wl_seat *seat EINA_UNUSED, const char *name EINA_UNUSED) +_cb_seat_event_free(void *data EINA_UNUSED, void *event) { - /* NB: No-Op as we don't care about seat name right now. - * - * This will likely change as we hash out remaining multi-seat issues */ + Ecore_Wl2_Event_Seat_Name *ev; + + ev = event; + eina_stringshare_del(ev->name); + free(ev); +} + +static void +_seat_cb_name(void *data, struct wl_seat *seat EINA_UNUSED, const char *name) +{ + Ecore_Wl2_Event_Seat_Name *ev; + Ecore_Wl2_Input *input; + + input = data; + + ev = calloc(1, sizeof(Ecore_Wl2_Event_Seat_Name)); + EINA_SAFETY_ON_NULL_RETURN(ev); + + ev->id = input->id; + ev->name = eina_stringshare_add(name); + + ecore_event_add(ECORE_WL2_EVENT_SEAT_NAME_CHANGED, ev, + _cb_seat_event_free, NULL); } static const struct wl_seat_listener _seat_listener = @@ -1241,6 +1261,7 @@ _ecore_wl2_input_add(Ecore_Wl2_Display *display, unsigned int id, unsigned int v input = calloc(1, sizeof(Ecore_Wl2_Input)); if (!input) return; + input->id = id; input->display = display; input->seat_version = version; input->repeat.rate = 0.025; diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h index ab619aa3c5..30f9d88473 100644 --- a/src/lib/ecore_wl2/ecore_wl2_private.h +++ b/src/lib/ecore_wl2/ecore_wl2_private.h @@ -405,6 +405,7 @@ struct _Ecore_Wl2_Input Ecore_Wl2_Offer *drag, *selection; unsigned int seat_version; + unsigned int id; }; typedef struct Ecore_Wl2_Event_Window_WWW 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 d420fb4489..980531ca72 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 @@ -44,7 +44,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[10]; +static Ecore_Event_Handler *_ecore_evas_wl_event_hdls[11]; static void _ecore_evas_wayland_resize(Ecore_Evas *ee, int location); @@ -535,6 +535,33 @@ _ecore_evas_wl_common_cb_global_removed(void *d EINA_UNUSED, int t EINA_UNUSED, return ECORE_CALLBACK_PASS_ON; } +static Eina_Bool +_ecore_evas_wl_common_cb_seat_name_changed(void *d EINA_UNUSED, int t EINA_UNUSED, void *event) +{ + Ecore_Wl2_Event_Seat_Name *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) + { + evas_device_name_set(device->seat, ev->name); + break; + } + } + } + + return ECORE_CALLBACK_PASS_ON; +} + int _ecore_evas_wl_common_init(void) { @@ -573,6 +600,9 @@ _ecore_evas_wl_common_init(void) _ecore_evas_wl_event_hdls[9] = ecore_event_handler_add(ECORE_WL2_EVENT_GLOBAL_REMOVED, _ecore_evas_wl_common_cb_global_removed, NULL); + _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_event_evas_init();