From 3f2bfe7f268fb6faba20abbf0fa4c788a73ee14e Mon Sep 17 00:00:00 2001 From: "duna.oh" Date: Fri, 15 Dec 2023 19:48:07 +0900 Subject: [PATCH] e_devicemgr: create new tizen_input_device resources for every seat & manager The commit '3cf250' was a workaround to fix memory leaks not destroying tizen_input_device resources. However, it also caused that second bound wl_seat (ex.efl_util) coundln't get events of tizen_input_device_manager. Also, since the memory leak issue was fixed by the commit '889ae7', we don't need the workaround. Please refer to following commits. commit 3cf250b83cc3d2038304045433aae23cad7b44fc Author: duna.oh Date: Thu Nov 10 14:34:33 2022 +0900 e_devicemgr: create tizen_input_devices only for first bound seat & manager commit 889ae7c41049cc2b7d7e598e2814ba7e551127e9 Author: duna.oh Date: Fri Nov 4 19:15:47 2022 +0900 e_devicemgr: add data struct for tizen_input_device_manager E_Devicemgr_Input_Device_Mgr_Data is a data for tizen_input_device_manager. This has a Eina_List of E_Device_Input_Device_User_Data and manager's resource. When a client unbinds tizen_input_device_manager, mgr_data iterates a list of device_user_data and cleans up device's resource. Change-Id: Ic3e0a898c07fc7c595233cabbb9ad4d6d6d5964c --- src/bin/e_comp_wl_input.c | 27 +-------------------------- src/bin/e_devicemgr_private.h | 1 - src/bin/e_devicemgr_wl.c | 34 +++------------------------------- 3 files changed, 4 insertions(+), 58 deletions(-) diff --git a/src/bin/e_comp_wl_input.c b/src/bin/e_comp_wl_input.c index 920a8e73df..58969185c0 100644 --- a/src/bin/e_comp_wl_input.c +++ b/src/bin/e_comp_wl_input.c @@ -466,46 +466,21 @@ static const struct wl_seat_interface _e_seat_interface = static void _e_comp_wl_input_cb_unbind_seat(struct wl_resource *resource) { - E_Comp_Wl_Seat *seat = wl_resource_get_user_data(resource); - DBG("Unbind seat: %u (client: %p)", wl_resource_get_id(resource), wl_resource_get_client(resource)); e_comp_wl->seat.resources = eina_list_remove(e_comp_wl->seat.resources, resource); - E_FREE(seat); } static void _e_comp_wl_input_cb_bind_seat(struct wl_client *client, void *data EINA_UNUSED, uint32_t version, uint32_t id) { struct wl_resource *res; - Eina_List *l; - struct wl_resource *tmp_res; - E_Comp_Wl_Seat *seat; - - seat = E_NEW(E_Comp_Wl_Seat, 1); - if (!seat) - { - ERR("Failed to allocate memory for seat data\n"); - wl_client_post_no_memory(client); - return; - } - seat->is_first_resource = 1; - - EINA_LIST_FOREACH(e_comp_wl->seat.resources, l, tmp_res) - { - if (wl_resource_get_client(tmp_res) != client) continue; - DBG("wl_seat (res: %d) is already bound to client (%p)", - wl_resource_get_id(tmp_res), client); - seat->is_first_resource = 0; - break; - } res = wl_resource_create(client, &wl_seat_interface, version, id); if (!res) { ERR("Could not create seat resource: %m"); - E_FREE(seat); return; } DBG("Bind seat: %u (client: %p)", wl_resource_get_id(res), client); @@ -516,7 +491,7 @@ _e_comp_wl_input_cb_bind_seat(struct wl_client *client, void *data EINA_UNUSED, eina_list_append(e_comp_wl->seat.resources, res); wl_resource_set_implementation(res, &_e_seat_interface, - seat, + NULL, _e_comp_wl_input_cb_unbind_seat); _e_comp_wl_input_update_seat_caps(client); diff --git a/src/bin/e_devicemgr_private.h b/src/bin/e_devicemgr_private.h index b8af2d6237..19206569f7 100644 --- a/src/bin/e_devicemgr_private.h +++ b/src/bin/e_devicemgr_private.h @@ -54,7 +54,6 @@ typedef struct _E_Devicemgr_Inputgen_Resource_Data E_Devicemgr_Inputgen_Resource struct _E_Devicemgr_Input_Device_Mgr_Data { struct wl_resource *resource; - Eina_Bool is_first_resource : 1; Eina_List *user_data_list; }; diff --git a/src/bin/e_devicemgr_wl.c b/src/bin/e_devicemgr_wl.c index 440a460e11..5f636e6bd5 100644 --- a/src/bin/e_devicemgr_wl.c +++ b/src/bin/e_devicemgr_wl.c @@ -137,12 +137,6 @@ e_devicemgr_wl_device_add(E_Devicemgr_Input_Device *dev) { seat_data = wl_resource_get_user_data(seat_res); if (!seat_data) continue; - if (!seat_data->is_first_resource) - { - DMDBG("The seat (res:%d) is not the first resource bound to client (%p)", - wl_resource_get_id(seat_res), wl_resource_get_client(seat_res)); - continue; - } wc = wl_resource_get_client(seat_res); @@ -150,12 +144,7 @@ e_devicemgr_wl_device_add(E_Devicemgr_Input_Device *dev) { dev_mgr_res = mgr_data->resource; if (wl_resource_get_client(dev_mgr_res) != wc) continue; - if (!mgr_data->is_first_resource) - { - DMDBG("This device_manager (res:%d) not the first resource bound to client (%p)", - wl_resource_get_id(dev_mgr_res), wc); - continue; - } + res = wl_resource_create(wc, &tizen_input_device_interface, 1, 0); if (!res) { @@ -634,7 +623,7 @@ _e_devicemgr_wl_cb_bind(struct wl_client *client, void *data, uint32_t version, E_Devicemgr_Input_Device *dev; struct wl_array axes; E_Devicemgr_Input_Device_User_Data *device_user_data; - E_Devicemgr_Input_Device_Mgr_Data *mgr_data, *tmp_data; + E_Devicemgr_Input_Device_Mgr_Data *mgr_data; mgr_data = E_NEW(E_Devicemgr_Input_Device_Mgr_Data, 1); if (!mgr_data) @@ -643,16 +632,6 @@ _e_devicemgr_wl_cb_bind(struct wl_client *client, void *data, uint32_t version, wl_client_post_no_memory(client); return; } - mgr_data->is_first_resource = 1; - - EINA_LIST_FOREACH(e_devicemgr->wl_data->mgr_data_list, l, tmp_data) - { - if (wl_resource_get_client(tmp_data->resource) != client) continue; - DMDBG("tizen_input_device_manager (res: %d) is already bound to client (%p)", - wl_resource_get_id(tmp_data->resource), client); - mgr_data->is_first_resource = 0; - break; - } if (!(res = wl_resource_create(client, &tizen_input_device_manager_interface, version, id))) { @@ -662,7 +641,7 @@ _e_devicemgr_wl_cb_bind(struct wl_client *client, void *data, uint32_t version, return; } - DMDBG("Bind tizen_input_device_manager: %u (client: %p)", wl_resource_get_id(res), wl_resource_get_client(res)); + DMINF("Bind tizen_input_device_manager: %u (client: %p)", wl_resource_get_id(res), wl_resource_get_client(res)); mgr_data->resource = res; mgr_data->user_data_list = NULL; @@ -683,13 +662,6 @@ _e_devicemgr_wl_cb_bind(struct wl_client *client, void *data, uint32_t version, e_devicemgr_wl_touch_max_count_send(e_devicemgr->max_touch_count, res, seat_res); } - if (!mgr_data->is_first_resource) - { - DMDBG("This device_manager (res:%d) is not the first resource bound to client (%p)", - wl_resource_get_id(res), client); - continue; - } - g_rec_mutex_lock(&e_devicemgr->device_list_mutex); EINA_LIST_FOREACH(e_devicemgr->device_list, ll, dev) { -- 2.34.1