remove the use of ec->zone 01/297601/3
authorSooChan Lim <sc1.lim@samsung.com>
Mon, 21 Aug 2023 10:43:11 +0000 (19:43 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 22 Aug 2023 23:21:55 +0000 (08:21 +0900)
use e_comp_zone_find_by_ec function instead

Change-Id: I5676d2225840dbe7a34b09a7f04a38a48580df5a

src/rotation/e_mod_rotation_wl.c

index 40a5f20..5cddeb9 100644 (file)
@@ -228,10 +228,14 @@ static Eina_Bool
 _no_active_lockscreen_check(E_Client *ec)
 {
    E_Client *ec2 = NULL;
+   E_Zone *zone;
    int x, y, w, h;
 
    if (!ec) return EINA_FALSE;
 
+   zone = e_comp_zone_find_by_ec(ec);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(zone, EINA_FALSE);
+
    /* NB: to set fg_ec to lockscreen, return true if given ec is lockscreen itself. */
    if (e_policy_client_is_lockscreen(ec)) return EINA_TRUE;
 
@@ -242,8 +246,7 @@ _no_active_lockscreen_check(E_Client *ec)
         if (e_policy_client_is_lockscreen(ec2))
           {
              e_client_geometry_get(ec2, &x, &y, &w, &h);
-             if (E_CONTAINS(ec->zone->x, ec->zone->y, ec->zone->w, ec->zone->h,
-                            x, y, w, h))
+             if (E_CONTAINS(zone->x, zone->y, zone->w, zone->h, x, y, w, h))
                {
                   /* lockscreen is shown on top of given ec. */
                   return EINA_FALSE;
@@ -308,10 +311,14 @@ _rot_client_cb_vis_prepare_foreground(void *data, Evas_Object *obj, void *event_
 {
    Policy_Ext_Rotation *rot;
    E_Client *ec;
+   E_Zone *zone;
 
    rot = data;
    ec = rot->ec;
 
+   zone = e_comp_zone_find_by_ec(ec);
+   EINA_SAFETY_ON_NULL_RETURN(zone);
+
    EDBG(ec, "Update Foreground Client '%s'(%p)", ec->icccm.name, ec);
    if (e_policy_visibility_client_is_activity(ec))
      {
@@ -333,13 +340,13 @@ _rot_client_cb_vis_prepare_foreground(void *data, Evas_Object *obj, void *event_
                }
 
              if (_camera_check(ec))
-               _unlock_rot_for_fg_app(ec->zone);
+               _unlock_rot_for_fg_app(zone);
              else
-               _try_lock_rot_for_fg_app(ec->zone);
+               _try_lock_rot_for_fg_app(zone);
           }
      }
 
-   _e_client_rotation_zone_set(ec->zone, ec, NULL);
+   _e_client_rotation_zone_set(zone, ec, NULL);
    if (ec->changes.rotation)
      {
         EDBG(ec, "Postpone foreground: ang %d", ec->e.state.rot.ang.next);
@@ -628,6 +635,7 @@ _e_tizen_rotation_ack_angle_change_cb(struct wl_client *client,
 {
    E_Client *ec;
    Policy_Ext_Rotation *rot;
+   E_Zone *zone;
 
    rot = wl_resource_get_user_data(resource);
    EINA_SAFETY_ON_NULL_RETURN(rot);
@@ -640,6 +648,9 @@ _e_tizen_rotation_ack_angle_change_cb(struct wl_client *client,
         TIZEN_ROTATION_ANGLE_TO_INT(rot->cur_angle),
         serial);
 
+   zone = e_comp_zone_find_by_ec(ec);
+   EINA_SAFETY_ON_NULL_RETURN(zone);
+
    if ((serial != 0) && (rot->serial == serial)) // rotation success
      {
         if (rot->angle_change_done)
@@ -656,7 +667,7 @@ _e_tizen_rotation_ack_angle_change_cb(struct wl_client *client,
         WRN("Rotation Zone Set: Rotation Done(fail case): %s(%p) Not matched serial %u != %u",
             ec->icccm.name ? ec->icccm.name : "", ec, rot->serial, serial);
 
-        _e_client_rotation_zone_set(ec->zone, ec, NULL);
+        _e_client_rotation_zone_set(zone, ec, NULL);
      }
 
    // check angle change serial
@@ -780,7 +791,7 @@ _e_tizen_policy_ext_active_angle_cb(struct wl_client *client, struct wl_resource
      {
         ec = e_client_from_surface_resource(surface);
         if (ec)
-          zone = ec->zone;
+          zone = e_comp_zone_find_by_ec(ec);
         else
           zone = e_zone_current_get();
      }
@@ -902,13 +913,15 @@ _rot_eval_fetch_available_send_angle_change(Policy_Ext_Rotation *rot)
         Eina_List *l;
         struct wl_resource *res;
         int ang_zone = 0;
+        E_Zone *zone;
 
-        if (ec->zone)
+        zone = e_comp_zone_find_by_ec(ec);
+        if (zone)
           {
-             if (ec->zone->rot.unknown_state)
-               ang_zone = ec->zone->rot.act;
+             if (zone->rot.unknown_state)
+               ang_zone = zone->rot.act;
              else
-               ang_zone = ec->zone->rot.curr;
+               ang_zone = zone->rot.curr;
 
              zone_tz_angle = INT_TO_TIZEN_ROTATION_ANGLE(ang_zone);
           }
@@ -963,6 +976,8 @@ _e_client_rotation_swap_check(E_Client *ec)
    // Check whether the width and height of ec are swapped or not.
    // If you want to make your swap policy, then you can modify this function.
 
+   E_Zone *zone;
+
    if (!e_config->wm_win_rotation_swap_size)
      return EINA_FALSE;
 
@@ -972,11 +987,14 @@ _e_client_rotation_swap_check(E_Client *ec)
        e_policy_client_is_keyboard_sub(ec))
      return EINA_FALSE;
 
+   zone = e_comp_zone_find_by_ec(ec);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(zone, EINA_FALSE);
+
    e_client_geometry_get(ec, &x, &y, &w, &h);
-   if ((x != ec->zone->x) ||
-       (y != ec->zone->y) ||
-       (w != ec->zone->w) ||
-       (h != ec->zone->h))
+   if ((x != zone->x) ||
+       (y != zone->y) ||
+       (w != zone->w) ||
+       (h != zone->h))
      return EINA_TRUE;
 
    return EINA_FALSE;
@@ -1067,6 +1085,10 @@ _e_client_rotation_list_remove(E_Client *ec)
 {
    E_Event_Client_Rotation_Change_End *ev = NULL;
    Eina_Bool found = EINA_FALSE;
+   E_Zone *zone;
+
+   zone = e_comp_zone_find_by_ec(ec);
+   EINA_SAFETY_ON_NULL_RETURN(zone);
 
    if (eina_list_data_find(rot.list, ec) == ec)
      {
@@ -1103,10 +1125,10 @@ _e_client_rotation_list_remove(E_Client *ec)
           }
         /* handling pending zone rotation job */
         else if ((eina_list_count(rot.list) == 0) &&
-                 (ec->zone->rot.wait_for_done) &&
-                 (ec->zone->rot.pending))
+                 (zone->rot.wait_for_done) &&
+                 (zone->rot.pending))
           {
-             e_zone_rotation_update_done(ec->zone);
+             e_zone_rotation_update_done(zone);
           }
      }
    ec->e.state.rot.ang.next = -1;
@@ -1188,7 +1210,7 @@ _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclud
 
    E_CLIENT_REVERSE_FOREACH(ec)
      {
-        if (ec->zone != zone) continue;
+        if (zone != e_comp_zone_find_by_ec(ec)) continue;
         if (ec == exclude_ec) continue;
         if ((ec != include_ec) && (!evas_object_visible_get(ec->frame))) continue;
         if (e_object_is_del(E_OBJECT(ec))) continue;
@@ -1806,11 +1828,15 @@ e_client_rotation_is_available(E_Client *ec, int ang)
    E_Client *below = NULL;
    Eina_Bool below_rot = EINA_TRUE;
    int ec_x, ec_y, ec_w, ec_h;
+   E_Zone *zone;
 
    if (ang < 0) return EINA_FALSE;
    if (!ec->e.state.rot.support)
      goto no_hint;
 
+   zone = e_comp_zone_find_by_ec(ec);
+   EINA_SAFETY_ON_NULL_GOTO(zone, no_hint);
+
    if (ec->e.state.rot.type == E_CLIENT_ROTATION_TYPE_DEPENDENT)
      {
         // check below fullsize window's angle
@@ -1820,8 +1846,8 @@ e_client_rotation_is_available(E_Client *ec, int ang)
         ec_h = ec->h;
         e_client_geometry_get(ec, &ec_x, &ec_y, &ec_w, &ec_h);
 
-        if ((ec_x == ec->zone->x) && (ec_y == ec->zone->y) &&
-            (ec_w == ec->zone->w) && (ec_h == ec->zone->h))
+        if ((ec_x == zone->x) && (ec_y == zone->y) &&
+            (ec_w == zone->w) && (ec_h == zone->h))
           {
              below = e_client_rotation_find_below(ec);
              if (below)
@@ -2399,8 +2425,12 @@ _e_tizen_rotation_smart_placement_apply(E_Client *ec)
    int new_x, new_y;
    int x1, y1, x2, y2;
    int zx, zy, zw, zh;
+   E_Zone *zone;
+
+   zone = e_comp_zone_find_by_ec(ec);
+   EINA_SAFETY_ON_NULL_RETURN(zone);
 
-   angle = ec->zone->rot.curr;
+   angle = zone->rot.curr;
 
    e_client_geometry_get(ec, &x, &y, &w, &h);
    new_x = x;
@@ -2411,10 +2441,10 @@ _e_tizen_rotation_smart_placement_apply(E_Client *ec)
    y1 = y;
    y2 = y+h;
 
-   zx = ec->zone->x;
-   zy = ec->zone->y;
-   zw = ec->zone->w;
-   zh = ec->zone->h;
+   zx = zone->x;
+   zy = zone->y;
+   zw = zone->w;
+   zh = zone->h;
 
    // calculate x position
    if (x1 < 0)
@@ -2661,6 +2691,7 @@ _rot_hook_client_del(void *d EINA_UNUSED, E_Client *ec)
 {
    Policy_Ext_Rotation *ext_rot;
    struct wl_resource *res;
+   E_Zone *zone;
 
    _e_client_rotation_list_remove(ec);
    if (rot.async_list) rot.async_list = eina_list_remove(rot.async_list, ec);
@@ -2694,16 +2725,23 @@ _rot_hook_client_del(void *d EINA_UNUSED, E_Client *ec)
         fg_ec = NULL;
 
         if (_camera_check(ec))
-          _try_lock_rot_for_fg_app(ec->zone);
+          {
+            zone = e_comp_zone_find_by_ec(ec);
+            if (zone) _try_lock_rot_for_fg_app(zone);
+          }
      }
 }
 
 static void
 _rot_hook_eval_end(void *d EINA_UNUSED, E_Client *ec)
 {
+   E_Zone *zone;
+
+   zone = e_comp_zone_find_by_ec(ec);
+   EINA_SAFETY_ON_NULL_RETURN(zone);
+
    if (ec->changes.rotation)
      {
-        E_Zone *zone = ec->zone;
         int ec_x, ec_y, ec_w, ec_h;
 
         if (ec->moving) e_client_act_move_end(ec, NULL);
@@ -2913,7 +2951,9 @@ end_fetch_rot:
    else if ((evas_object_visible_get(ec->frame) && (ec->e.fetch.rot.need_rotation)))
      {
         DBG("Rotation Zone Set: Fetch Hint");
-        _e_client_rotation_zone_set(ec->zone, NULL, NULL);
+        E_Zone *zone;
+        zone = e_comp_zone_find_by_ec(ec);
+        if (zone) _e_client_rotation_zone_set(zone, NULL, NULL);
      }
 
    if (ec->e.fetch.rot.need_rotation)
@@ -2934,6 +2974,7 @@ static Eina_Bool
 _rot_fg_set(E_Client *ec, Eina_Bool check_obscured)
 {
    Policy_Ext_Rotation *rot;
+   E_Zone *zone;
 
    rot = eina_hash_find(rot_hash, &ec);
    if (!rot)
@@ -2953,6 +2994,9 @@ _rot_fg_set(E_Client *ec, Eina_Bool check_obscured)
    if (ec->e.state.rot.pending_show)
      return EINA_FALSE;
 
+   zone = e_comp_zone_find_by_ec(ec);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(zone, EINA_FALSE);
+
    if (e_policy_visibility_client_is_activity(ec))
      {
         EDBG(ec, "Check ec %x to set fg_ec", e_client_util_win_get(ec));
@@ -2976,13 +3020,13 @@ _rot_fg_set(E_Client *ec, Eina_Bool check_obscured)
                }
 
              if (_camera_check(ec))
-               _unlock_rot_for_fg_app(ec->zone);
+               _unlock_rot_for_fg_app(zone);
              else
-               _try_lock_rot_for_fg_app(ec->zone);
+               _try_lock_rot_for_fg_app(zone);
           }
      }
 
-   _e_client_rotation_zone_set(ec->zone, ec, NULL);
+   _e_client_rotation_zone_set(zone, ec, NULL);
    if (ec->changes.rotation)
      {
         EDBG(ec, "Postpone show: ang %d", ec->e.state.rot.ang.next);
@@ -3011,21 +3055,26 @@ _rot_intercept_hook_show_helper(void *d EINA_UNUSED, E_Client *ec)
 static Eina_Bool
 _rot_intercept_hook_hide(void *d EINA_UNUSED, E_Client *ec)
 {
+   E_Zone *zone;
+
    // TODO: Add VKBD Hide, VKBD Parent Hide routine.
    // clear pending_show, because this window is hidden now.
    ec->e.state.rot.pending_show = 0;
 
+   zone = e_comp_zone_find_by_ec(ec);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(zone, EINA_TRUE);
+
    if (fg_ec == ec)
      {
         EDBG(ec, "Set the fg_ec to NULL");
         fg_ec = NULL;
 
         if (_camera_check(ec))
-          _try_lock_rot_for_fg_app(ec->zone);
+          _try_lock_rot_for_fg_app(zone);
      }
 
    // for rotating ec in the force_update_list
-   _e_client_rotation_zone_set(ec->zone, fg_ec, ec);
+   _e_client_rotation_zone_set(zone, fg_ec, ec);
 
    return EINA_TRUE;
 }
@@ -3079,11 +3128,14 @@ _rot_cb_idle_enterer(void *data EINA_UNUSED)
         else if (n > 1)
           {
              Eina_Bool rot_block = EINA_FALSE;
+             E_Zone *zone;
 
              EINA_LIST_FOREACH(rot.list, l, ec)
                {
-                  if (!ec->zone) continue;
-                  if (ec->zone->rot.block.mod_count)
+                  zone = e_comp_zone_find_by_ec(ec);
+                  if (!zone) continue;
+
+                  if (zone->rot.block.mod_count)
                     {
                        rot_block = EINA_TRUE;
                     }
@@ -3109,9 +3161,13 @@ _rot_cb_idle_enterer(void *data EINA_UNUSED)
                {
                   EINA_LIST_FREE(rot.async_list, ec)
                     {
-                       if (!eina_list_data_find(zlist, ec->zone))
-                         zlist = eina_list_append(zlist, ec->zone);
-                       _e_client_rotation_change_message_send(ec);
+                       zone = e_comp_zone_find_by_ec(ec);
+                       if (zone)
+                         {
+                            if (!eina_list_data_find(zlist, zone))
+                              zlist = eina_list_append(zlist, zone);
+                            _e_client_rotation_change_message_send(ec);
+                         }
                     }
 
                   EINA_LIST_FOREACH(zlist, l, zone)