e_client: Introduce e_client_from_surface_resource() 53/292553/2
authorSeunghun Lee <shiin.lee@samsung.com>
Tue, 9 May 2023 05:00:50 +0000 (14:00 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 10 May 2023 04:41:03 +0000 (04:41 +0000)
The wl_resource_get_user_data() has been used to get the corresponding
E_Client instance. To stop using wl_resource_get_user_data() directly,
this patch introduces a wrapper API. So, from now on,
e_client_from_surface_resource() has to be used instead of
wl_resource_get_user_data().

There could be some advantages with this API.

Firstly, as long as this API keeps returning E_Client instance, we can
change user data of surface resource if necessary.

Secondly, e_client_from_surface_resource() can check given surface
resource to see if it's actually associated with E_Client. If given
wl_resource isn't the one associated with E_Client, then it could return
NULL so that the caller would fail fast. Or, the caller would end up
manipulating the returned pointer of wl_resource_get_user_data() without
knowing it's not the correct instance.

Change-Id: I7fdc19a6b4cba647c314c32ae36ab847ca459ff7

src/bin/e_client.c
src/bin/e_client.h

index bba77cf..6269ea2 100644 (file)
@@ -9113,3 +9113,9 @@ e_client_is_layout_apply(E_Client *ec)
    if (!ec) return EINA_FALSE;
    return ec->apply_layout;
 }
+
+E_API E_Client *
+e_client_from_surface_resource(struct wl_resource *surface_resource)
+{
+   return wl_resource_get_user_data(surface_resource);
+}
index a4d1cd5..873dfe2 100644 (file)
@@ -1124,6 +1124,7 @@ E_API extern int E_EVENT_CLIENT_FOCUS_SKIP_UNSET;
 EINTERN void e_client_idler_before(void);
 EINTERN Eina_Bool e_client_init(void);
 EINTERN void e_client_shutdown(void);
+E_API E_Client *e_client_from_surface_resource(struct wl_resource *surface_resource);
 E_API E_Client *e_client_new(E_Pixmap *cp, int first_map, int internal);
 E_API Eina_Bool e_client_is_internal(E_Client *ec);
 E_API void e_client_unignore(E_Client *ec);