subsurface: add a function checking circular reference for subsurface. 22/241222/2
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 13 May 2020 08:32:34 +0000 (17:32 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Sun, 23 Aug 2020 23:36:36 +0000 (23:36 +0000)
Change-Id: I25bf7c5ed840f6aa8d121462658b061590e18613

src/bin/e_comp_wl_subsurface.c

index da985f58256ab16b4c4099e04994c4bd858c0587..867f336b5be7504b2f96f94b945bc54f269b2ec3 100644 (file)
@@ -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 */