From: Seunghun Lee Date: Tue, 22 Sep 2020 02:59:22 +0000 (+0900) Subject: subsurface: Raise a protocol error about wl_subsurface.place_(above/below). X-Git-Tag: submit/tizen/20201028.025427~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=634a93f81bbafb5677918f77895d31fd64a9a165;p=platform%2Fupstream%2Fenlightenment.git subsurface: Raise a protocol error about wl_subsurface.place_(above/below). Check for bad sibling and raise the required error. Change-Id: Id5c066f0cd6434353793ed800bbe216ae6d10075 --- diff --git a/src/bin/e_comp_wl_subsurface.c b/src/bin/e_comp_wl_subsurface.c index 5c8d6bf0e2..3c4b05d986 100644 --- a/src/bin/e_comp_wl_subsurface.c +++ b/src/bin/e_comp_wl_subsurface.c @@ -542,6 +542,29 @@ _e_comp_wl_subsurface_cb_position_set(struct wl_client *client EINA_UNUSED, stru sdata->position.set = EINA_TRUE; } +static Eina_Bool +_subsurface_sibling_check(E_Client *ec1, E_Client *ec2) +{ + E_Client *parent, *sibling; + Eina_List *l; + + parent = ec1->comp_data->sub.data->parent; + + EINA_LIST_FOREACH(parent->comp_data->sub.list_pending, l, sibling) + { + if ((sibling != ec1) && (sibling == ec2)) + return EINA_TRUE; + } + + EINA_LIST_FOREACH(parent->comp_data->sub.below_list_pending, l, sibling) + { + if ((sibling != ec1) && (sibling == ec2)) + return EINA_TRUE; + } + + return EINA_FALSE; +} + static void _e_comp_wl_subsurface_cb_place_above(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *sibling_resource) { @@ -563,6 +586,15 @@ _e_comp_wl_subsurface_cb_place_above(struct wl_client *client EINA_UNUSED, struc if (!(parent = ec->comp_data->sub.data->parent)) return; if (e_object_is_del(E_OBJECT(parent)) || !parent->comp_data) return; + if (!_subsurface_sibling_check(ec, ecs)) + { + wl_resource_post_error(ec->comp_data->sub.data->resource, + WL_SUBSURFACE_ERROR_BAD_SURFACE, + "%s: wl_surface@%d is not a parent or sibling", + "place_above", wl_resource_get_id(ecs->comp_data->surface)); + return; + } + parent->comp_data->sub.list_pending = eina_list_remove(parent->comp_data->sub.list_pending, ec); @@ -593,6 +625,15 @@ _e_comp_wl_subsurface_cb_place_below(struct wl_client *client EINA_UNUSED, struc if (!(parent = ec->comp_data->sub.data->parent)) return; if (e_object_is_del(E_OBJECT(parent)) || !parent->comp_data) return; + if (!_subsurface_sibling_check(ec, ecs)) + { + wl_resource_post_error(ec->comp_data->sub.data->resource, + WL_SUBSURFACE_ERROR_BAD_SURFACE, + "%s: wl_surface@%d is not a parent or sibling", + "place_below", wl_resource_get_id(ecs->comp_data->surface)); + return; + } + parent->comp_data->sub.list_pending = eina_list_remove(parent->comp_data->sub.list_pending, ec);