From 4ca46c8d6c641ea6d5640c1bb3bb9a5ab1dd4470 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Wed, 13 May 2020 17:32:34 +0900 Subject: [PATCH] subsurface: add a function checking circular reference for subsurface. Change-Id: I25bf7c5ed840f6aa8d121462658b061590e18613 --- src/bin/e_comp_wl_subsurface.c | 42 +++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/bin/e_comp_wl_subsurface.c b/src/bin/e_comp_wl_subsurface.c index da985f5825..867f336b5b 100644 --- a/src/bin/e_comp_wl_subsurface.c +++ b/src/bin/e_comp_wl_subsurface.c @@ -5,6 +5,8 @@ static struct wl_global *global = NULL; static Eina_List *hooks = NULL; +static Eina_Bool _e_comp_wl_subsurface_circular_reference_check(E_Client *ec, E_Client *parent); + static void _e_comp_wl_subsurface_restack_bg_rectangle(E_Client *ec) { @@ -813,6 +815,23 @@ _e_comp_wl_subsurface_synchronized_get(E_Comp_Wl_Subsurf_Data *sdata) return EINA_FALSE; } +static Eina_Bool +_e_comp_wl_subsurface_circular_reference_check(E_Client *ec, E_Client *parent) +{ + while(parent) + { + if (ec == parent) + return EINA_TRUE; + + if ((parent->comp_data) && (parent->comp_data->sub.data)) + parent = parent->comp_data->sub.data->parent; + else + break; + } + + return EINA_FALSE; +} + EINTERN Eina_Bool e_comp_wl_subsurfaces_init(E_Comp_Wl_Data *wl_comp) { @@ -890,25 +909,12 @@ e_comp_wl_subsurface_create(E_Client *ec, E_Client *epc, uint32_t id, struct wl_ } // check parent relationship is a cycle + if (_e_comp_wl_subsurface_circular_reference_check(ec, epc)) { - E_Client *parent = epc; - - while(parent) - { - if (ec == parent) - { - ERR("Subsurface parent relationship is a cycle : [child win : %zx, %s], [parent win : %zx, %s]", - e_client_util_win_get(ec), e_client_util_name_get(ec), - e_client_util_win_get(epc), e_client_util_name_get(epc)); - - return EINA_FALSE; - } - - if ((parent->comp_data) && (parent->comp_data->sub.data)) - parent = parent->comp_data->sub.data->parent; - else - break; - } + ERR("Subsurface parent relationship is a cycle : [child win : %zx, %s], [parent win : %zx, %s]", + e_client_util_win_get(ec), e_client_util_name_get(ec), + e_client_util_win_get(epc), e_client_util_name_get(epc)); + return EINA_FALSE; } /* try to allocate subsurface data */ -- 2.34.1