e_comp_wl_subsurface: Utilize E_Surface 77/315677/2
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 31 Jul 2024 05:32:49 +0000 (14:32 +0900)
committerJunSeok Kim <juns.kim@samsung.com>
Tue, 6 Aug 2024 05:18:13 +0000 (05:18 +0000)
Change-Id: I4a585cc8303215b240cdecc59c3bc50c970844ba

src/bin/server/e_comp_wl_subsurface.c
src/bin/server/e_compositor.c
src/bin/server/e_compositor_intern.h

index 150937d..b636d66 100644 (file)
@@ -1,6 +1,7 @@
 #include "e_comp_wl_subsurface_intern.h"
 #include "e_comp_wl_intern.h"
 #include "e_comp_wl_viewport_intern.h"
+#include "e_compositor_intern.h"
 #include "e_pixmap_intern.h"
 #include "e_client_video_intern.h"
 #include "e_client_intern.h"
@@ -700,16 +701,30 @@ EINTERN Eina_Bool
 e_comp_wl_subsurface_check(E_Client *ec)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
-   return ec->comp_data ? !!ec->comp_data->sub.data : EINA_FALSE;
+
+   return !!e_subsurface_try_from_ec(ec);
 }
 
 EINTERN E_Client *
 e_comp_wl_subsurface_parent_get(E_Client *ec)
 {
+   E_Surface *surface;
+   E_Subsurface *subsurface;
+
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL);
-   /* Must be called with valid comp_data. */
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL);
-   return ec->comp_data->sub.data ? ec->comp_data->sub.data->parent : NULL;
+
+   surface = e_surface_try_from_ec(ec);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(surface, NULL);
+
+   subsurface = e_subsurface_try_from_surface(surface);
+   if (!subsurface)
+     return NULL;
+
+   surface = e_subsurface_parent_try_get(subsurface);
+   if (!surface)
+     return NULL;
+
+   return e_surface_ec_get(surface);
 }
 
 EINTERN Eina_Bool
index 5959e8a..1ae12b5 100644 (file)
@@ -650,11 +650,20 @@ e_subsurface_from_ec(E_Client *ec)
 {
    E_Subsurface *subsurface;
 
-   assert(ec->comp_data->sub.data);
+   assert(ec->comp_data && ec->comp_data->sub.data);
 
    return wl_container_of(ec->comp_data->sub.data, subsurface, base);
 }
 
+EINTERN E_Subsurface *
+e_subsurface_try_from_ec(E_Client *ec)
+{
+   if ((!ec->comp_data) || (!ec->comp_data->sub.data))
+     return NULL;
+
+   return e_subsurface_from_ec(ec);
+}
+
 EINTERN Eina_Bool
 e_subsurface_position_set(E_Subsurface *subsurface, int x, int y)
 {
index 7b28257..dfdfae7 100644 (file)
@@ -47,6 +47,7 @@ E_Subsurface *e_subsurface_create(struct wl_resource *factory_resource, uint32_t
 E_Subsurface *e_subsurface_from_resource(struct wl_resource *resource);
 E_Subsurface *e_subsurface_try_from_surface(E_Surface *surface);
 E_Subsurface *e_subsurface_from_ec(E_Client *ec);
+E_Subsurface *e_subsurface_try_from_ec(E_Client *ec);
 Eina_Bool e_subsurface_position_set(E_Subsurface *subsurface, int x, int y);
 void e_subsurface_destroy_listener_add(E_Subsurface *subsurface, struct wl_listener *listener);
 void e_subsurface_reposition_listener_add(E_Subsurface *subsurface, struct wl_listener *listener);