From: Jihoon Kim Date: Tue, 23 May 2023 07:40:38 +0000 (+0900) Subject: Add surface mutex X-Git-Tag: accepted/tizen/unified/20230706.152207~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F84%2F295184%2F2;p=platform%2Fupstream%2Fenlightenment.git Add surface mutex Change-Id: I3f9bb241ec19b36feb4f1f51a647124a3914ee21 Signed-off-by: Jihoon Kim --- diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c index ab028d8..bf80c40 100644 --- a/src/bin/e_comp_wl.c +++ b/src/bin/e_comp_wl.c @@ -3456,7 +3456,10 @@ _e_comp_wl_surface_destroy(struct wl_resource *resource) } } + g_mutex_lock(&ec->comp_data->surface_mutex); ec->comp_data->surface = NULL; + g_mutex_unlock(&ec->comp_data->surface_mutex); + ec->comp_data->wl_surface = NULL; e_pixmap_win_id_del(ec->pixmap); @@ -3542,7 +3545,9 @@ _e_comp_wl_compositor_cb_surface_create(struct wl_client *client, struct wl_reso ec->new_client = 0; if ((!ec->client.w) && (ec->client.h)) ec->client.w = ec->client.h = 1; + g_mutex_lock(&ec->comp_data->surface_mutex); ec->comp_data->surface = res; + g_mutex_unlock(&ec->comp_data->surface_mutex); ec->icccm.accepts_focus = 1; wl_list_init(&ec->comp_data->pointer_constraints); } @@ -3893,6 +3898,7 @@ _e_comp_wl_client_cb_new(void *data EINA_UNUSED, E_Client *ec) e_pixmap_cdata_set(ec->pixmap, ec->comp_data); g_mutex_init(&ec->comp_data->last_device_kbd_mutex); + g_mutex_init(&ec->comp_data->surface_mutex); end: TRACE_DS_END(); @@ -3910,6 +3916,7 @@ _e_comp_wl_client_cb_del(void *data EINA_UNUSED, E_Client *ec) TRACE_DS_BEGIN(COMP_WL:CLIENT DEL CB); g_mutex_clear(&ec->comp_data->last_device_kbd_mutex); + g_mutex_clear(&ec->comp_data->surface_mutex); _e_comp_wl_hook_call(E_COMP_WL_HOOK_DEL, ec); diff --git a/src/bin/e_comp_wl.h b/src/bin/e_comp_wl.h index 44556d3..91643cc 100644 --- a/src/bin/e_comp_wl.h +++ b/src/bin/e_comp_wl.h @@ -524,6 +524,7 @@ struct _E_Comp_Wl_Client_Data Eina_Bool wtz_surface_assigned; struct wl_list pointer_constraints; GMutex last_device_kbd_mutex; + GMutex surface_mutex; }; struct _E_Comp_Wl_Output diff --git a/src/bin/e_comp_wl_input.c b/src/bin/e_comp_wl_input.c index 06eff15..a059810 100644 --- a/src/bin/e_comp_wl_input.c +++ b/src/bin/e_comp_wl_input.c @@ -128,13 +128,18 @@ _e_comp_wl_input_pointer_cb_cursor_set(struct wl_client *client, struct wl_resou { E_Client *ec; Eina_Bool got_mouse = EINA_FALSE; + struct wl_resource *surface; E_CLIENT_FOREACH(ec) { if (e_object_is_del(E_OBJECT(ec))) continue; if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) continue; - if (!ec->comp_data->surface) continue; - if (client != wl_resource_get_client(ec->comp_data->surface)) continue; + g_mutex_lock(&ec->comp_data->surface_mutex); + surface = ec->comp_data->surface; + g_mutex_unlock(&ec->comp_data->surface_mutex); + + if (!surface) continue; + if (client != wl_resource_get_client(surface)) continue; if (ec->mouse.in && ec->pointer_enter_sent) { got_mouse = EINA_TRUE; @@ -316,6 +321,7 @@ e_comp_wl_input_keyboard_enter_send(E_Client *ec) serial = wl_display_next_serial(e_comp_wl->wl.disp); + g_mutex_lock(&ec->comp_data->surface_mutex); EINA_LIST_FOREACH(e_comp_wl->kbd.focused, l, res) { wl_keyboard_send_enter(res, serial, ec->comp_data->surface, @@ -326,6 +332,7 @@ e_comp_wl_input_keyboard_enter_send(E_Client *ec) e_comp_wl->kbd.mod_locked, e_comp_wl->kbd.mod_group); } + g_mutex_unlock(&ec->comp_data->surface_mutex); } static void diff --git a/src/bin/e_comp_wl_subsurface.c b/src/bin/e_comp_wl_subsurface.c index 9aa4cdb..baa1e91 100644 --- a/src/bin/e_comp_wl_subsurface.c +++ b/src/bin/e_comp_wl_subsurface.c @@ -1598,7 +1598,10 @@ _e_comp_wl_subsurface_ec_link(E_Subsurface *sub, E_Client *ec) _e_comp_wl_subsurface_cb_comp_data_del, sub); + g_mutex_lock(&ec->comp_data->surface_mutex); ec->comp_data->surface = ec->comp_data->wl_surface; + g_mutex_unlock(&ec->comp_data->surface_mutex); + ec->comp_data->sub.data = &sub->base; e_comp_wl_surface_state_init(&sub->base.cached, ec->w, ec->h);