screen_rotation: Use ds_tizen_screen_rotation 89/314989/2
authorTaeHyeon Jeong <thyeon.jeong@samsung.com>
Mon, 15 Jul 2024 06:46:36 +0000 (15:46 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Thu, 25 Jul 2024 06:13:34 +0000 (06:13 +0000)
Change-Id: I1fa8ba5b941825c178a34e1567429c2631629e13

src/bin/server/e_screen_rotation.c

index 7d99e93..20b760b 100644 (file)
 #include "e_screen_rotation_intern.h"
 #include "e_client_intern.h"
 
-#include <tizen-extension-server-protocol.h>
+#include <libds-tizen/screen_rotation.h>
 
 typedef struct _E_Comp_Screen_Tzsr
 {
-   struct wl_resource *resource; /* tizen_screen_rotation */
-   E_Client           *ec;
-   struct wl_listener ec_destroy;
+   struct ds_tizen_screen_rotation_info *info;
+   E_Client *ec;
+       struct wl_listener destroy;
 } E_Comp_Screen_Tzsr;
 
 static Eina_List *tzsr_list;
 
-static void _tz_screen_rotation_cb_ec_destroy(struct wl_listener *listener, void *data);
+static struct wl_listener transform;
 
 static E_Comp_Screen_Tzsr*
 _tz_surface_rotation_find(E_Client *ec)
 {
-   E_Comp_Screen_Tzsr *tzsr = NULL;
-   struct wl_listener *listener;
-
-   listener = e_client_destroy_listener_get(ec, _tz_screen_rotation_cb_ec_destroy);
-   if (listener)
-     return wl_container_of(listener, tzsr, ec_destroy);
+   E_Comp_Screen_Tzsr *tzsr;
+   Eina_List *l, *ll;
 
-   return tzsr;
-}
+       EINA_LIST_FOREACH_SAFE(tzsr_list, l, ll, tzsr)
+     {
+        if (tzsr->ec == ec)
+                         return tzsr;
+     }
 
-static void
-_tz_surface_rotation_free(E_Comp_Screen_Tzsr *tzsr)
-{
-   ELOGF("TRANSFORM", "|tzsr(%p) freed", tzsr->ec, tzsr);
-   tzsr_list = eina_list_remove(tzsr_list, tzsr);
-   wl_list_remove(&tzsr->ec_destroy.link);
-   free(tzsr);
+       return NULL;
 }
 
 static void
-_tz_screen_rotation_cb_ec_destroy(struct wl_listener *listener, void *data)
+_tz_screen_rotation_info_cb_destroy(struct wl_listener *listener, void *data)
 {
    E_Comp_Screen_Tzsr *tzsr;
 
-   tzsr = wl_container_of(listener, tzsr, ec_destroy);
-   _tz_surface_rotation_free(tzsr);
+   tzsr = wl_container_of(listener, tzsr, destroy);
+   tzsr_list = eina_list_remove(tzsr_list, tzsr);
+       free(tzsr);
 }
 
 static void
-_tz_screen_rotation_get_ignore_output_transform(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface)
+_tz_screen_rotation_cb_get_ignore_output_transform(struct wl_listener *listener, void *data)
 {
+       struct ds_tizen_screen_rotation_info *info;
+       struct ds_surface *ds_surface;
+   struct wl_resource *surface_resource;
    E_Comp_Screen_Tzsr *tzsr;
-   E_Client *ec;
-   E_Hwc_Policy hwc_policy;
-   E_Output *output;
-   E_Zone *zone;
-   Eina_Bool ignore = EINA_TRUE;
-
-   ec = e_client_from_surface_resource(surface);
-   EINA_SAFETY_ON_NULL_RETURN(ec);
-
-   tzsr = _tz_surface_rotation_find(ec);
-   if (tzsr) return;
-
-   tzsr = E_NEW(E_Comp_Screen_Tzsr, 1);
-   if (!tzsr)
-     {
-        wl_client_post_no_memory(client);
-        return;
-     }
-
-   tzsr->resource = resource;
-   tzsr->ec = ec;
-
-   tzsr->ec_destroy.notify = _tz_screen_rotation_cb_ec_destroy;
-   e_client_destroy_listener_add(ec, &tzsr->ec_destroy);
-
-   tzsr_list = eina_list_append(tzsr_list, tzsr);
+       E_Client *ec;
 
-   zone = e_comp_zone_find_by_ec(ec);
-   if (zone)
-     {
-        output = e_output_find(zone->output_id);
-        if (output)
-          {
-             hwc_policy = e_hwc_policy_get(output->hwc);
-             if (hwc_policy == E_HWC_POLICY_WINDOWS)
-               ignore = EINA_FALSE;
-          }
-     }
-
-   ELOGF("TRANSFORM", "|tzsr(%p) client_ignore(%d) ignore(%d)",
-         ec, tzsr, e_config->screen_rotation_client_ignore, ignore);
+       info = (struct ds_tizen_screen_rotation_info*)data;
+       EINA_SAFETY_ON_NULL_RETURN(info);
 
-   e_comp_screen_rotation_ignore_output_transform_send(ec, ignore);
-}
+       ds_surface = ds_tizen_screen_rotation_info_get_surface(info);
+       EINA_SAFETY_ON_NULL_RETURN(ds_surface);
 
-static void
-_tz_screen_rotation_iface_cb_destroy(struct wl_client *client, struct wl_resource *resource)
-{
-   wl_resource_destroy(resource);
-}
+   surface_resource = ds_surface_get_wl_resource(ds_surface);
+   EINA_SAFETY_ON_NULL_RETURN(surface_resource);
 
-static const struct tizen_screen_rotation_interface _tz_screen_rotation_interface =
-{
-   _tz_screen_rotation_get_ignore_output_transform,
-   _tz_screen_rotation_iface_cb_destroy,
-};
+   ec = e_client_from_surface_resource(surface_resource);
+   EINA_SAFETY_ON_NULL_RETURN(surface_resource);
 
-static void _tz_screen_rotation_cb_destroy(struct wl_resource *resource)
-{
-   E_Comp_Screen_Tzsr *tzsr;
-   Eina_List *l, *ll;
 
-   EINA_LIST_FOREACH_SAFE(tzsr_list, l, ll, tzsr)
+   tzsr = E_NEW(E_Comp_Screen_Tzsr, 1);
+   if (!tzsr)
      {
-        if (tzsr->resource == resource)
-          _tz_surface_rotation_free(tzsr);
+         ERR("E_Comp_Screen_Tzsr alloc fail");
      }
-}
 
-static void
-_tz_screen_rotation_cb_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
-{
-   struct wl_resource *res;
+       tzsr->ec = ec;
+       tzsr->info = info;
+       tzsr->destroy.notify = _tz_screen_rotation_info_cb_destroy;
+       ds_tizen_screen_rotation_info_add_destroy_listener(info, &tzsr->destroy);
 
-   if (!(res = wl_resource_create(client, &tizen_screen_rotation_interface, version, id)))
-     {
-        ERR("Could not create tizen_screen_rotation resource: %m");
-        wl_client_post_no_memory(client);
-        return;
-     }
-
-   wl_resource_set_implementation(res, &_tz_screen_rotation_interface, NULL, _tz_screen_rotation_cb_destroy);
+       tzsr_list = eina_list_append(tzsr_list, tzsr);
 }
 
 EINTERN Eina_Bool
 e_screen_rotation_init()
 {
-   if (!wl_global_create(e_comp_wl->wl.disp, &tizen_screen_rotation_interface, 1,
-                         NULL, _tz_screen_rotation_cb_bind))
+   struct ds_tizen_screen_rotation *screen_rotation;
+   screen_rotation = ds_tizen_screen_rotation_create(e_comp_wl->wl.disp);
+
+   if (!screen_rotation)
      {
         ERR("Could not add tizen_screen_rotation to wayland globals");
      }
 
-   return EINA_TRUE;
+       transform.notify = _tz_screen_rotation_cb_get_ignore_output_transform;
+       ds_tizen_screen_rotation_add_get_ignore_output_transform_info_listener(screen_rotation, &transform);
+
+       return EINA_TRUE;
 }
 
 EINTERN void
@@ -154,19 +101,16 @@ EINTERN void
 e_screen_rotation_ignore_output_transform_send(E_Client *ec, Eina_Bool ignore)
 {
    E_Comp_Screen_Tzsr *tzsr;
-   E_Comp_Wl_Client_Data *cdata;
-
    tzsr = _tz_surface_rotation_find(ec);
-   if (!tzsr) return;
+   EINA_SAFETY_ON_NULL_RETURN(tzsr);
 
    ELOGF("TRANSFORM", "|tzsr(%p) ignore_output_transform(%d)", ec, tzsr, ignore);
 
-   cdata = e_client_cdata_get(ec);
-   tizen_screen_rotation_send_ignore_output_transform(tzsr->resource, cdata->surface, ignore);
+       ds_tizen_screen_rotation_send_ignore_output_transform(tzsr->info, ignore);
 }
 
 EINTERN Eina_Bool
 e_screen_rotation_ignore_output_transform_watch(E_Client *ec)
 {
    return (_tz_surface_rotation_find(ec)) ? EINA_TRUE : EINA_FALSE;
-}
+}
\ No newline at end of file