rotation: remove module circular dependency 81/248681/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Tue, 1 Dec 2020 10:14:49 +0000 (19:14 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Tue, 1 Dec 2020 10:14:49 +0000 (19:14 +0900)
Change-Id: I0203ffbdd663d2daa83c5e36f14baf5fb87c3e35

src/e_mod_config.c
src/e_mod_main.c
src/e_mod_main.h
src/rotation/e_mod_rotation.c
src/rotation/e_mod_rotation.h
src/rotation/e_mod_rotation_wl.c

index 467080f..79b07e3 100644 (file)
@@ -34,29 +34,19 @@ e_mod_pol_conf_shutdown(Mod *mod)
    E_CONFIG_DD_FREE(mod->conf_edd);
 }
 
-EINTERN Eina_Bool
-e_mod_pol_conf_rot_enable_get(int angle)
+EINTERN Eina_List *
+e_mod_pol_conf_rot_enable_angles_get(void)
 {
-   Config_Rot *rot;
-   Eina_List *rots, *l;
+   Eina_List *rots = NULL;
 
    if (EINA_UNLIKELY(!_pol_mod))
-     return EINA_FALSE;
+     return NULL;
 
    if (EINA_UNLIKELY(!_pol_mod->conf))
-     return EINA_FALSE;
+     return NULL;
 
    rots = _pol_mod->conf->rotations;
-   if (!rots)
-     return EINA_FALSE;
-
-   EINA_LIST_FOREACH(rots, l, rot)
-     {
-        if (rot->angle == angle)
-          return !!rot->enable;
-     }
-
-   return EINA_FALSE;
+   return rots;
 }
 
 EINTERN Eina_Bool
index 1ba1cba..19881e9 100644 (file)
@@ -53,6 +53,14 @@ _tz_profile_type_get(void)
    return p;
 }
 
+static void
+_e_mod_pol_rotation_init(void)
+{
+   Eina_List *angle_list = NULL;
+
+   angle_list = e_mod_pol_conf_rot_enable_angles_get();
+   e_mod_pol_rotation_init(angle_list);
+}
 
 E_API void *
 e_modapi_init(E_Module *m)
@@ -69,7 +77,7 @@ e_modapi_init(E_Module *m)
      ERR("No policy system!");
 
    e_mod_pol_conf_init(mod);
-   e_mod_pol_rotation_init();
+   _e_mod_pol_rotation_init();
    e_mod_pol_pingpong_init();
    e_mod_configured_resolution_init();
    if (_tz_profile_type_get() == TZ_PROFILE_TYPE_IVI)
index 2b29a8c..548c28e 100644 (file)
@@ -62,6 +62,6 @@ extern Mod *_pol_mod;
 
 EINTERN void             e_mod_pol_conf_init(Mod *mod);
 EINTERN void             e_mod_pol_conf_shutdown(Mod *mod);
-EINTERN Eina_Bool        e_mod_pol_conf_rot_enable_get(int angle);
+EINTERN Eina_List *      e_mod_pol_conf_rot_enable_angles_get(void);
 EINTERN Eina_Bool        e_mod_pol_conf_use_pingpoing_policy_get(void);
 #endif
index 3762ae4..4cdbee5 100644 (file)
 
 const static char *_wr_log_dom_name = "e-rot";
 
+typedef struct _Rot_Info   Rot_Info;
+struct _Rot_Info
+{
+   unsigned char    enable;
+   int              angle;
+};
+
 int _wr_log_dom = -1;
 static Eina_List *_event_handlers = NULL;
+static Eina_List *_config_enable_angles = NULL;
 
-/* externally accessible functions */
-/**
- * @describe
- *  Get current rotation angle.
- * @param      ec             e_client
- * @return     int            current angle
- */
-EINTERN int
-e_client_rotation_curr_angle_get(const E_Client *ec)
+EINTERN Eina_Bool
+e_mod_pol_rotation_is_conf_enable_angle(int angle)
 {
-   E_OBJECT_CHECK_RETURN(ec, -1);
-   E_OBJECT_TYPE_CHECK_RETURN(ec, E_CLIENT_TYPE, -1);
+   Eina_List *l;
+   Rot_Info *rot;
+
+   if (!_config_enable_angles)
+     return EINA_FALSE;
 
-   return ec->e.state.rot.ang.curr;
+   EINA_LIST_FOREACH(_config_enable_angles, l, rot)
+     {
+        if (rot->angle == angle)
+          return !!rot->enable;
+     }
+
+   return EINA_FALSE;
 }
 
 static Eina_Bool
@@ -87,7 +97,7 @@ _e_mod_pol_rotation_cb_idle_exiter(void *data EINA_UNUSED)
 }
 
 EINTERN void
-e_mod_pol_rotation_init(void)
+e_mod_pol_rotation_init(Eina_List *angle_list)
 {
    E_Zone *zone;
    Eina_List *l;
@@ -101,6 +111,8 @@ e_mod_pol_rotation_init(void)
 
    eina_log_domain_level_set(_wr_log_dom_name, EINA_LOG_LEVEL_INFO);
 
+   _config_enable_angles = eina_list_clone(angle_list);
+
    e_mod_rot_settings_init();
 #ifdef HAVE_AUTO_ROTATION
    e_mod_sensord_init();
@@ -138,6 +150,9 @@ err_log:
 EINTERN void
 e_mod_pol_rotation_shutdown(void)
 {
+   if (_config_enable_angles)
+     eina_list_free(_config_enable_angles);
+
   e_mod_rot_settings_shutdown();
 #ifdef HAVE_AUTO_ROTATION
   e_mod_sensord_deinit();
index ba8a40e..7da44b3 100644 (file)
@@ -13,8 +13,8 @@ typedef enum
 
 #include "e_mod_rotation_wl.h"
 
-EINTERN int       e_client_rotation_curr_angle_get(const E_Client *ec);
-EINTERN void      e_mod_pol_rotation_init(void);
+EINTERN Eina_Bool e_mod_pol_rotation_is_conf_enable_angle(int angle);
+EINTERN void      e_mod_pol_rotation_init(Eina_List *angle_list);
 EINTERN void      e_mod_pol_rotation_shutdown(void);
 EINTERN void      e_mod_pol_rotation_force_update_add(E_Zone *zone, E_Client *ec);
 EINTERN void      e_mod_pol_rotation_force_update_del(E_Zone *zone, E_Client *ec);
index 3d5d2d0..c653bbc 100644 (file)
@@ -18,6 +18,7 @@
  * license.
  */
 #include "e_mod_main.h"
+#include "e_mod_rotation.h"
 #include "e_mod_rotation_wl.h"
 #include "e_mod_rotation_private.h"
 #include <wayland-server.h>
@@ -435,7 +436,7 @@ _e_tizen_rotation_set_preferred_angle_cb(struct wl_client *client,
 
    ELOGF("ROTATION", "Request to set Preferred angle:%d", ec, TIZEN_ROTATION_ANGLE_TO_INT(angle));
    if ((angle != TIZEN_ROTATION_ANGLE_NONE) &&
-       (!e_mod_pol_conf_rot_enable_get(TIZEN_ROTATION_ANGLE_TO_INT(angle))))
+       (!e_mod_pol_rotation_is_conf_enable_angle(TIZEN_ROTATION_ANGLE_TO_INT(angle))))
      {
         ELOGF("ROTATION", "Preferred angle(%d) is not allowed. CONF disabled",
               ec, TIZEN_ROTATION_ANGLE_TO_INT(angle));
@@ -1021,7 +1022,7 @@ static Eina_Bool
 _e_client_rotation_angle_is_allowed(E_Client *ec, int angle)
 {
    if ((!_camera_check(ec)) &&
-       (!e_mod_pol_conf_rot_enable_get(angle)))
+       (!e_mod_pol_rotation_is_conf_enable_angle(angle)))
      {
         EDBG(ec, "CHECK dependent '%s'(%p) ang:%d rot.type:%d dependent:%d",
              ec->icccm.name, ec, angle,
@@ -1174,7 +1175,7 @@ _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclud
                         *  rotation list.
                         */
                        if ((!zone->rot.block.sys_auto_rot) &&
-                           (e_mod_pol_conf_rot_enable_get(cur_angle)) &&
+                           (e_mod_pol_rotation_is_conf_enable_angle(cur_angle)) &&
                            (ec->visibility.obscured != E_VISIBILITY_FULLY_OBSCURED))
                          {
                             ELOGF("ROTATION", "Do rotation of below ec under bg_ec %s(%p)",
@@ -1986,7 +1987,7 @@ e_zone_rotation_set(E_Zone *zone, int rotation)
             (zone->rot.block.mod_count > 0))
           {
              if ((!zone->rot.unblock.app_hint) &&
-                 (!e_mod_pol_conf_rot_enable_get(rotation)))
+                 (!e_mod_pol_rotation_is_conf_enable_angle(rotation)))
                {
                   ELOGF("ROTATION", "ZONE_ROT |SKIP|zone:%d curr:%d rotation:%d config is not allowed",
                         NULL, zone->num, zone->rot.curr, rotation);
@@ -2050,7 +2051,7 @@ e_zone_rotation_block_get(E_Zone *zone, int rot)
      }
 
    /* 2. not supported angle in wm-policy configuration */
-   if (!e_mod_pol_conf_rot_enable_get(rot))
+   if (!e_mod_pol_rotation_is_conf_enable_angle(rot))
      {
         ELOGF("ROTATION", "BLOCK Get. CONF disabled", NULL);
         return EINA_TRUE;