screen_rotation: Change tzsr free logic 97/314997/2
authorTaeHyeon Jeong <thyeon.jeong@samsung.com>
Thu, 18 Jul 2024 06:41:44 +0000 (15:41 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Thu, 25 Jul 2024 06:14:35 +0000 (06:14 +0000)
Change-Id: I63d8784499c11125ac00a22e1e38f9e8671a9843

src/bin/server/e_screen_rotation.c

index 7bf2b69..5bdf2a0 100644 (file)
@@ -8,12 +8,12 @@ typedef struct _E_Comp_Screen_Tzsr
    struct ds_tizen_screen_rotation_info *info;
    E_Client *ec;
    struct wl_listener ec_destroy;
+   struct wl_listener res_destroy;
 } E_Comp_Screen_Tzsr;
 
 static Eina_List *tzsr_list;
 
 static struct wl_listener transform;
-static struct wl_listener gsr_destroy;
 static struct ds_tizen_screen_rotation *g_screen_rotation = NULL;
 
 static void _tz_screen_rotation_cb_ec_destroy(struct wl_listener *listener, void *data);
@@ -38,6 +38,7 @@ _tz_screen_rotation_free(E_Comp_Screen_Tzsr *tzsr)
 
    tzsr_list = eina_list_remove(tzsr_list, tzsr);
    wl_list_remove(&tzsr->ec_destroy.link);
+   wl_list_remove(&tzsr->res_destroy.link);
 
    free(tzsr);
 }
@@ -52,6 +53,15 @@ _tz_screen_rotation_cb_ec_destroy(struct wl_listener *listener, void *data)
 }
 
 static void
+_tz_screen_rotation_cb_res_destroy(struct wl_listener *listener, void *data)
+{
+   E_Comp_Screen_Tzsr *tzsr;
+   tzsr = wl_container_of(listener, tzsr, res_destroy);
+
+   _tz_screen_rotation_free(tzsr);
+}
+
+static void
 _tz_screen_rotation_cb_get_ignore_output_transform(struct wl_listener *listener, void *data)
 {
    E_Comp_Screen_Tzsr *tzsr;
@@ -87,6 +97,8 @@ _tz_screen_rotation_cb_get_ignore_output_transform(struct wl_listener *listener,
    tzsr->info = info;
    tzsr->ec_destroy.notify = _tz_screen_rotation_cb_ec_destroy;
    e_client_destroy_listener_add(ec, &tzsr->ec_destroy);
+   tzsr->res_destroy.notify = _tz_screen_rotation_cb_res_destroy;
+   ds_tizen_screen_rotation_info_add_destroy_listener(info, &tzsr->res_destroy);
 
    tzsr_list = eina_list_append(tzsr_list, tzsr);
 
@@ -108,18 +120,6 @@ _tz_screen_rotation_cb_get_ignore_output_transform(struct wl_listener *listener,
    e_comp_screen_rotation_ignore_output_transform_send(ec, ignore);
 }
 
-static void
-_tz_screen_rotation_cb_destroy(struct wl_listener *listener, void *data)
-{
-   E_Comp_Screen_Tzsr *tzsr;
-   Eina_List *l, *ll;
-
-   EINA_LIST_FOREACH_SAFE(tzsr_list, l, ll, tzsr)
-     {
-        _tz_screen_rotation_free(tzsr);
-     }
-}
-
 EINTERN Eina_Bool
 e_screen_rotation_init()
 {
@@ -136,9 +136,6 @@ e_screen_rotation_init()
    transform.notify = _tz_screen_rotation_cb_get_ignore_output_transform;
    ds_tizen_screen_rotation_add_get_ignore_output_transform_info_listener(g_screen_rotation, &transform);
 
-   gsr_destroy.notify = _tz_screen_rotation_cb_destroy;
-   ds_tizen_screen_rotation_add_destroy_listener(g_screen_rotation, &gsr_destroy);
-
    return EINA_TRUE;
 }