From b097827b4a42077136a41e13d832aa23bf1797c6 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Wed, 3 Apr 2024 15:18:15 +0900 Subject: [PATCH] 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: I92b49e1ca5b90bd1ee4ef43a058b7495a39796aa --- src/bin/e_comp_wl_subsurface.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/bin/e_comp_wl_subsurface.c b/src/bin/e_comp_wl_subsurface.c index 55fd572..ebe333e 100644 --- a/src/bin/e_comp_wl_subsurface.c +++ b/src/bin/e_comp_wl_subsurface.c @@ -892,7 +892,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); @@ -901,10 +903,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; } -- 2.7.4