From: Seunghun Lee Date: Wed, 3 Apr 2024 06:18:15 +0000 (+0900) Subject: subsurface: Calculate global coordinates with all ancestors X-Git-Tag: accepted/tizen/8.0/unified/20240405.142131~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F52%2F309152%2F1;p=platform%2Fupstream%2Fenlightenment.git subsurface: Calculate global coordinates with all ancestors The 'x' and 'y' member variables of E_Client for a subsurface are only updated when its subsurface position needs to be updated. In other words, if there's no update made on the position using wl_subsurface.set_position, they would remain at their default values, which are zero. Therefore, we need to consider calculating the global coordinates of the subsurface considering the positions of all its ancestors. Change-Id: If4cc88c5c537a4b217edee49906d7e575367d920 --- diff --git a/src/bin/e_comp_wl_subsurface.c b/src/bin/e_comp_wl_subsurface.c index 371bba605b..4520f8d603 100644 --- a/src/bin/e_comp_wl_subsurface.c +++ b/src/bin/e_comp_wl_subsurface.c @@ -884,7 +884,9 @@ e_comp_wl_subsurface_position_get(E_Client *ec, int *x, int *y) EINTERN Eina_Bool e_comp_wl_subsurface_global_coord_get(E_Client *ec, int *x, int *y) { + E_Client *parent; E_Comp_Wl_Subsurf_Data *sdata; + int ret_x = 0, ret_y = 0; EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE); EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE); @@ -893,10 +895,28 @@ e_comp_wl_subsurface_global_coord_get(E_Client *ec, int *x, int *y) sdata = ec->comp_data->sub.data; EINA_SAFETY_ON_NULL_RETURN_VAL(sdata, EINA_FALSE); + while (1) + { + ret_x += sdata->position.x; + ret_y += sdata->position.y; + + parent = sdata->parent; + if (!parent) + break; + + sdata = _e_comp_wl_subsurface_data_get(parent); + if (!sdata) + { + ret_x += parent->x; + ret_y += parent->y; + break; + } + } + if (x) - *x = sdata->position.x + (sdata->parent ? sdata->parent->x : 0); + *x = ret_x; if (y) - *y = sdata->position.y + (sdata->parent ? sdata->parent->y : 0); + *y = ret_y; return EINA_TRUE; }