surface: Simplify ds_surface_is_ancestor_of() 97/295797/2
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 13 Jul 2023 08:02:08 +0000 (17:02 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Fri, 14 Jul 2023 01:35:14 +0000 (01:35 +0000)
This also moves the surface_is_ancestor_of() to private header.

Change-Id: Ie099d68b2bff1b5786d0440809197b0327f8667f

src/compositor/compositor_private.h
src/compositor/subsurface.c
src/compositor/surface.c
src/surface.h

index 84b00c4..b474802 100644 (file)
@@ -43,4 +43,7 @@ void subsurface_commit(struct ds_subsurface *subsurface);
 void subsurface_parent_commit(struct ds_subsurface *subsurface,
         bool synchronized);
 
+bool surface_is_ancestor_of(struct ds_surface *surface,
+        struct ds_surface *target_surface);
+
 #endif
index 0b2aafc..d9aaa62 100644 (file)
@@ -42,7 +42,7 @@ create_subsurface(struct wl_resource *factory_resource,
         return NULL;
     }
 
-    if (ds_surface_is_ancestor_of(surface, parent)) {
+    if (surface_is_ancestor_of(surface, parent)) {
         ds_inf("ds_surface(%p) is an ancestor of given parent(%p)",
                 surface, parent);
         wl_resource_post_error(factory_resource,
index 5401b5f..5f883cc 100644 (file)
@@ -248,23 +248,20 @@ create_surface(struct wl_client *client, uint32_t version, uint32_t id)
 }
 
 bool
-ds_surface_is_ancestor_of(struct ds_surface *surface,
+surface_is_ancestor_of(struct ds_surface *surface,
         struct ds_surface *target_surface)
 {
-    struct ds_subsurface *target_subsurface;
-    struct ds_surface *parent_surface;
+    struct ds_subsurface *subsurface;
+    struct ds_surface *iter = target_surface;
 
-    while (target_surface &&
-            ds_surface_is_subsurface(target_surface)) {
-        target_subsurface = ds_subsurface_from_surface(target_surface);
-        if (!target_subsurface)
+    while (iter) {
+        subsurface = ds_subsurface_from_surface(iter);
+        if (!subsurface)
             break;
 
-        parent_surface = subsurface_get_parent(target_subsurface);
-        if (surface == parent_surface)
+        iter = subsurface_get_parent(subsurface);
+        if (surface == iter)
             return true;
-
-        target_surface = parent_surface;
     }
 
     return false;
index 24e12d8..fbb092a 100644 (file)
@@ -9,10 +9,6 @@ bool
 ds_surface_has_buffer(struct ds_surface *surface);
 
 bool
-ds_surface_is_ancestor_of(struct ds_surface *surface,
-        struct ds_surface *target_surface);
-
-bool
 ds_surface_is_subsurface(struct ds_surface *surface);
 
 #endif