From: Seunghun Lee Date: Thu, 5 Nov 2020 07:47:49 +0000 (+0900) Subject: subsurface: fix changing stack order of sub-surface with its parent. X-Git-Tag: submit/tizen/20201109.083635~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e37668bbe7f047e135123dc0eb23f959f4f4777;p=platform%2Fupstream%2Fenlightenment.git subsurface: fix changing stack order of sub-surface with its parent. Sub-surface can be placed above or below of its parent by passing its sub-surface with its parent as arguments to wl_subsurface_place_above/below according to wl_subsurface description. However, until now enlightenment seems not to have been supported this operation correctly. In other words, enlightenment wasn't able to handle stacking order of sub-surface in case wl_subsurface_place_above/below is required with a parent of sub-surface. This patch corrects it. Change-Id: Icd65bf1759f1c7a3b950f6c9c222a41c9817a8ae --- diff --git a/src/bin/e_comp_wl_subsurface.c b/src/bin/e_comp_wl_subsurface.c index 572841655a..73a31cf67a 100644 --- a/src/bin/e_comp_wl_subsurface.c +++ b/src/bin/e_comp_wl_subsurface.c @@ -13,6 +13,9 @@ static void _e_comp_wl_subsurface_parent_commit(E_Client *ec, Eina_Bool pa static Eina_Bool _e_comp_wl_subsurface_synchronized_get(E_Comp_Wl_Subsurf_Data *sdata); static void _e_comp_wl_subsurface_synchronized_commit(E_Client *ec); static void _e_comp_wl_subsurface_remove_from_parent(E_Client *parent, E_Client *subc); +static void _e_comp_wl_subsurface_child_remove(E_Comp_Wl_Client_Data *parent_cdata, E_Client *child); +static void _e_comp_wl_subsurface_place_above(E_Client *parent, E_Client *subc, E_Client *above); +static void _e_comp_wl_subsurface_place_below(E_Client *parent, E_Client *subc, E_Client *below); static void _e_comp_wl_subsurface_restack_bg_rectangle(E_Client *ec) @@ -334,18 +337,18 @@ _e_comp_wl_subsurface_order_commit(E_Client *ec) if (!ec->comp_data->sub.list_changed) return (EINA_FALSE | need_restack); ec->comp_data->sub.list_changed = EINA_FALSE; + E_FREE_FUNC(ec->comp_data->sub.list, eina_list_free); /* TODO: need to check more complicated subsurface tree */ EINA_LIST_FOREACH(ec->comp_data->sub.list_pending, l, subc) { - ec->comp_data->sub.list = eina_list_remove(ec->comp_data->sub.list, subc); ec->comp_data->sub.list = eina_list_append(ec->comp_data->sub.list, subc); _e_comp_wl_subsurface_order_commit(subc); } + E_FREE_FUNC(ec->comp_data->sub.below_list, eina_list_free); EINA_LIST_FOREACH(ec->comp_data->sub.below_list_pending, l, subc) { - ec->comp_data->sub.below_list = eina_list_remove(ec->comp_data->sub.below_list, subc); ec->comp_data->sub.below_list = eina_list_append(ec->comp_data->sub.below_list, subc); _e_comp_wl_subsurface_order_commit(subc); @@ -596,15 +599,7 @@ _e_comp_wl_subsurface_cb_place_above(struct wl_client *client EINA_UNUSED, struc return; } - if (!ecs->comp_data->sub.data) return; - - parent->comp_data->sub.list_pending = - eina_list_remove(parent->comp_data->sub.list_pending, ec); - - parent->comp_data->sub.list_pending = - eina_list_append_relative(parent->comp_data->sub.list_pending, ec, ecs); - - parent->comp_data->sub.list_changed = EINA_TRUE; + _e_comp_wl_subsurface_place_above(parent, ec, ecs); } static void @@ -635,15 +630,7 @@ _e_comp_wl_subsurface_cb_place_below(struct wl_client *client EINA_UNUSED, struc return; } - if (!ecs->comp_data->sub.data) return; - - parent->comp_data->sub.list_pending = - eina_list_remove(parent->comp_data->sub.list_pending, ec); - - parent->comp_data->sub.list_pending = - eina_list_prepend_relative(parent->comp_data->sub.list_pending, ec, ecs); - - parent->comp_data->sub.list_changed = EINA_TRUE; + _e_comp_wl_subsurface_place_below(parent, ec, ecs); } static void @@ -1369,3 +1356,73 @@ _e_comp_wl_subsurface_data_get(E_Client *ec) { return (ec->comp_data) ? (ec->comp_data->sub.data) : NULL; } + +static void +_e_comp_wl_subsurface_child_remove(E_Comp_Wl_Client_Data *parent_cdata, E_Client *child) +{ + if (parent_cdata->sub.list_pending) + { + parent_cdata->sub.list_pending = + eina_list_remove(parent_cdata->sub.list_pending, child); + } + if (parent_cdata->sub.below_list_pending) + { + parent_cdata->sub.below_list_pending = + eina_list_remove(parent_cdata->sub.below_list_pending, child); + } +} + +static void +_e_comp_wl_subsurface_place_above(E_Client *parent, E_Client *subc, E_Client *above) +{ + E_Comp_Wl_Client_Data *pc; + + pc = parent->comp_data; + + _e_comp_wl_subsurface_child_remove(pc, subc); + + if (parent == above) + { + pc->sub.list_pending = eina_list_prepend(pc->sub.list_pending, subc); + } + else if (eina_list_data_find(pc->sub.list_pending, above)) + { + pc->sub.list_pending = + eina_list_append_relative(pc->sub.list_pending, subc, above); + } + else + { + pc->sub.below_list_pending = + eina_list_append_relative(pc->sub.below_list_pending, subc, above); + } + + pc->sub.list_changed = EINA_TRUE; +} + +static void +_e_comp_wl_subsurface_place_below(E_Client *parent, E_Client *subc, E_Client *below) +{ + E_Comp_Wl_Client_Data *pc; + + pc = parent->comp_data; + + _e_comp_wl_subsurface_child_remove(pc, subc); + + if (parent == below) + { + pc->sub.below_list_pending = + eina_list_append(pc->sub.below_list_pending, subc); + } + else if (eina_list_data_find(pc->sub.list_pending, below)) + { + pc->sub.list_pending = + eina_list_prepend_relative(pc->sub.list_pending, subc, below); + } + else + { + pc->sub.below_list_pending = + eina_list_prepend_relative(pc->sub.below_list_pending, subc, below); + } + + pc->sub.list_changed = EINA_TRUE; +} diff --git a/src/bin/e_policy_wl.c b/src/bin/e_policy_wl.c index c61a7a788f..43f8a3e3ec 100644 --- a/src/bin/e_policy_wl.c +++ b/src/bin/e_policy_wl.c @@ -2058,6 +2058,7 @@ _tzpol_iface_cb_subsurf_place_below_parent(struct wl_client *client EINA_UNUSED, ELOGF("TZPOL", "SUBSURF|BELOW_PARENT", ec); epc->comp_data->sub.list = eina_list_remove(epc->comp_data->sub.list, ec); epc->comp_data->sub.list_pending = eina_list_remove(epc->comp_data->sub.list_pending, ec); + epc->comp_data->sub.below_list_pending = eina_list_append(epc->comp_data->sub.below_list_pending, ec); epc->comp_data->sub.below_list = eina_list_append(epc->comp_data->sub.below_list, ec); epc->comp_data->sub.list_changed = EINA_TRUE; }