From d35b0af64ab6b2fb60a89064d4378dc6c92795dc Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Tue, 22 Sep 2020 11:59:22 +0900 Subject: [PATCH] subsurface: Raise a protocol error about wl_subsurface.place_(above/below). Check for bad sibling and raise the required error. Change-Id: Iaa2af9818e35c62fbc8b15ed5222c4bc431eba2a --- src/bin/e_comp_wl_subsurface.c | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) 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); -- 2.34.1