From 620b8b585112b0ce495eda726197d58509b09edf Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Wed, 31 Jul 2024 14:32:49 +0900 Subject: [PATCH] e_comp_wl_subsurface: Utilize E_Surface Change-Id: I4a585cc8303215b240cdecc59c3bc50c970844ba --- src/bin/server/e_comp_wl_subsurface.c | 23 +++++++++++++++++++---- src/bin/server/e_compositor.c | 11 ++++++++++- src/bin/server/e_compositor_intern.h | 1 + 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/bin/server/e_comp_wl_subsurface.c b/src/bin/server/e_comp_wl_subsurface.c index 150937d..b636d66 100644 --- a/src/bin/server/e_comp_wl_subsurface.c +++ b/src/bin/server/e_comp_wl_subsurface.c @@ -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 diff --git a/src/bin/server/e_compositor.c b/src/bin/server/e_compositor.c index 5959e8a..1ae12b5 100644 --- a/src/bin/server/e_compositor.c +++ b/src/bin/server/e_compositor.c @@ -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) { diff --git a/src/bin/server/e_compositor_intern.h b/src/bin/server/e_compositor_intern.h index 7b28257..dfdfae7 100644 --- a/src/bin/server/e_compositor_intern.h +++ b/src/bin/server/e_compositor_intern.h @@ -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); -- 2.7.4