e_mod_rotation: send early angle change evt at eval_fetch 46/218146/2
authorJuyeon Lee <juyeonne.lee@samsung.com>
Wed, 20 Nov 2019 03:55:36 +0000 (12:55 +0900)
committerJuyeon Lee <juyeonne.lee@samsung.com>
Wed, 20 Nov 2019 04:49:17 +0000 (13:49 +0900)
the early angle change event is made only for landscape(90|270) client if it
dismatch with rot.curr.
rotation available/preferre request come serveral in sequence, than
apply last req.

with this commit(by calculating in eval_fetch time whether the early
 angle_change event is needed or not) the event flow is going to be changed like below.

condition: curr angle is 0
from
   S <- C   tizen_rotation@37.set_available_angles(2)
   S -> C   tizen_rotation@37.angle_change(2, 243) ====> Angle change 90
   S <- C   tizen_rotation@37.set_available_angles(10)
   S <- C   tizen_rotation@37.set_available_angles(11)
   S <- C   tizen_rotation@37.set_available_angles(15)
   S <- C   tizen_rotation@37.ack_angle_change(243)
   S -> C   tizen_rotation@37.angle_change(1, 245) ===> Angle change 0
   S <- C   tizen_rotation@37.ack_angle_change(245)

to
   S <- C   tizen_rotation@37.set_available_angles(2)
   S <- C   tizen_rotation@37.set_available_angles(10)
   S <- C   tizen_rotation@37.set_available_angles(11)
   S <- C   tizen_rotation@37.set_available_angles(15)

Change-Id: Ib8f03c9ce6c0ed3270e218133cdb6b0b818adc27

src/rotation/e_mod_rotation_wl.c

index c1855f5..3330761 100644 (file)
@@ -389,7 +389,6 @@ _e_tizen_rotation_set_available_angles_cb(struct wl_client *client,
 {
    E_Client *ec;
    Policy_Ext_Rotation *rot;
-   enum tizen_rotation_angle cur_tz_angle;
 
    rot = wl_resource_get_user_data(resource);
    EINA_SAFETY_ON_NULL_RETURN(rot);
@@ -402,60 +401,6 @@ _e_tizen_rotation_set_available_angles_cb(struct wl_client *client,
 
    ec->e.fetch.rot.available_rots = 1;
    EC_CHANGED(ec);
-
-   cur_tz_angle = INT_TO_TIZEN_ROTATION_ANGLE(ec->e.state.rot.ang.curr);
-   if (rot->available_angles & cur_tz_angle)
-     {
-        EDBG(ec, "Ignore it. current angle(%d) is one of available angles.", cur_tz_angle);
-        return;
-     }
-
-   /* for clients supporting landscape mode only */
-   if ((rot->available_angles) &&
-       !(rot->available_angles & TIZEN_ROTATION_ANGLE_0) &&
-       !(rot->available_angles & TIZEN_ROTATION_ANGLE_180))
-     {
-        enum tizen_rotation_angle tz_angle = 0;
-        uint32_t serial;
-        Eina_List *l;
-        struct wl_resource *res;
-
-        if (rot->available_angles & TIZEN_ROTATION_ANGLE_90)
-          tz_angle = TIZEN_ROTATION_ANGLE_90;
-        else if (rot->available_angles & TIZEN_ROTATION_ANGLE_270)
-          tz_angle = TIZEN_ROTATION_ANGLE_270;
-        else
-          {
-             ERR("What's this impossible angle?? : %d", rot->available_angles);
-          }
-
-        if (tz_angle)
-          {
-             /* if the client requests a window rotation with the same value as the current angle, just ignore it. */
-             if ((ec->first_mapped) &&
-                 (ec->e.state.rot.ang.curr == TIZEN_ROTATION_ANGLE_TO_INT(tz_angle)))
-               {
-                  EDBG(ec, "Ignore it. given angle %d is same as the current angle for landscape only app.",
-                       tz_angle);
-                  return;
-               }
-
-             serial = wl_display_next_serial(e_comp_wl->wl.disp);
-
-             EDBG(ec, "Send Change Rotation: angle %d for redering preparation of landscape only app. mapped:%d serial:%u",
-                  tz_angle, ec->first_mapped, serial);
-
-             rot->angle_change_done = EINA_FALSE;
-             rot->prev_angle = rot->cur_angle;
-             rot->cur_angle = tz_angle;
-             rot->serial = serial;
-
-             EINA_LIST_FOREACH(rot->rotation_list, l, res)
-               {
-                  tizen_rotation_send_angle_change(res, tz_angle, serial);
-               }
-          }
-     }
 }
 
 static void
@@ -491,30 +436,25 @@ _e_tizen_rotation_set_preferred_angle_cb(struct wl_client *client,
         return;
      }
 
-   /* for clients supporting landscape mode only and clients supporting portrait mode in floating state*/
-   if (rot->preferred_angle)
+   /* for clients supporting portrait mode in floating state*/
+   if ((rot->preferred_angle) &&
+       !(rot->preferred_angle & TIZEN_ROTATION_ANGLE_90) &&
+       !(rot->preferred_angle & TIZEN_ROTATION_ANGLE_270))
      {
         enum tizen_rotation_angle tz_angle = 0;
         uint32_t serial;
         Eina_List *l;
         struct wl_resource *res;
 
-        if (rot->preferred_angle & TIZEN_ROTATION_ANGLE_90)
-          tz_angle = TIZEN_ROTATION_ANGLE_90;
-        else if (rot->preferred_angle & TIZEN_ROTATION_ANGLE_270)
-          tz_angle = TIZEN_ROTATION_ANGLE_270;
-        else
+        if ((ec->floating) && (ec->comp_data) && ((ec->comp_data->shell.window.w != ec->w) || (ec->comp_data->shell.window.h != ec->h)))
           {
-             if ((ec->floating) && (ec->comp_data) && ((ec->comp_data->shell.window.w != ec->w) || (ec->comp_data->shell.window.h != ec->h)))
+             if (rot->preferred_angle & TIZEN_ROTATION_ANGLE_0)
+               tz_angle = TIZEN_ROTATION_ANGLE_0;
+             else if (rot->preferred_angle & TIZEN_ROTATION_ANGLE_180)
+               tz_angle = TIZEN_ROTATION_ANGLE_180;
+             else
                {
-                  if (rot->preferred_angle & TIZEN_ROTATION_ANGLE_0)
-                    tz_angle = TIZEN_ROTATION_ANGLE_0;
-                  else if (rot->preferred_angle & TIZEN_ROTATION_ANGLE_180)
-                    tz_angle = TIZEN_ROTATION_ANGLE_180;
-                  else
-                    {
-                       ERR("What's this impossible angle?? : %d", rot->preferred_angle);
-                    }
+                  ERR("What's this impossible angle?? : %d", rot->preferred_angle);
                }
           }
 
@@ -544,13 +484,6 @@ _e_tizen_rotation_set_preferred_angle_cb(struct wl_client *client,
                        ec->e.state.rot.preferred_rot = TIZEN_ROTATION_ANGLE_TO_INT(angle);
                        return;
                     }
-                  else if ((tz_angle == TIZEN_ROTATION_ANGLE_90) || (tz_angle == TIZEN_ROTATION_ANGLE_270))
-                    {
-                       EDBG(ec, "Send Change Rotation: angle %d for rendering preparation of landscape mode only app. mapped:%d serial:%u",
-                            tz_angle, ec->first_mapped, serial);
-
-                       tizen_rotation_send_angle_change(res, tz_angle, serial);
-                    }
                }
           }
      }
@@ -797,6 +730,136 @@ _e_tizen_policy_ext_bind_cb(struct wl_client *client, void *data, uint32_t versi
    wl_resource_set_implementation(res, &_e_tizen_policy_ext_interface, NULL, NULL);
 }
 
+static Eina_Bool
+_rot_eval_fetch_preferred_send_angle_change(Policy_Ext_Rotation *rot)
+{
+   E_Client *ec;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(rot, EINA_FALSE);
+
+   ec = rot->ec;
+   if (!ec)
+     return EINA_FALSE;
+
+   if (!rot->preferred_angle)
+     return EINA_FALSE;
+
+   /* for clients supporting landscape mode only */
+   if (!(rot->preferred_angle & TIZEN_ROTATION_ANGLE_0) &&
+       !(rot->preferred_angle & TIZEN_ROTATION_ANGLE_180))
+     {
+        enum tizen_rotation_angle tz_angle = 0;
+        uint32_t serial;
+        Eina_List *l;
+        struct wl_resource *res;
+
+        if (rot->available_angles & TIZEN_ROTATION_ANGLE_90)
+          tz_angle = TIZEN_ROTATION_ANGLE_90;
+        else if (rot->available_angles & TIZEN_ROTATION_ANGLE_270)
+          tz_angle = TIZEN_ROTATION_ANGLE_270;
+        else
+          {
+             ERR("What's this impossible angle?? : %d", rot->preferred_angle);
+          }
+
+        if (tz_angle)
+          {
+             serial = wl_display_next_serial(e_comp_wl->wl.disp);
+
+             rot->angle_change_done = EINA_FALSE;
+             rot->prev_angle = rot->cur_angle;
+             rot->cur_angle = tz_angle;
+             rot->serial = serial;
+
+             EDBG(ec, "Send Change Rotation: angle %d for rendering preparation of landscape mode only app. mapped:%d serial:%u",
+                  tz_angle, ec->first_mapped, serial);
+
+             ec->e.state.rot.ang.next = TIZEN_ROTATION_ANGLE_TO_INT(tz_angle);
+
+             EINA_LIST_FOREACH(rot->rotation_list, l, res)
+               {
+                  tizen_rotation_send_angle_change(res, tz_angle, serial);
+               }
+             return EINA_TRUE;
+          }
+     }
+
+   return EINA_FALSE;
+}
+
+static Eina_Bool
+_rot_eval_fetch_available_send_angle_change(Policy_Ext_Rotation *rot)
+{
+   enum tizen_rotation_angle cur_tz_angle;
+   E_Client *ec;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(rot, EINA_FALSE);
+
+   ec = rot->ec;
+   if (!ec)
+     return EINA_FALSE;
+
+   if (!rot->available_angles)
+     return EINA_FALSE;
+
+   cur_tz_angle = INT_TO_TIZEN_ROTATION_ANGLE(ec->e.state.rot.ang.curr);
+   if (rot->available_angles & cur_tz_angle)
+     {
+        EDBG(ec, "Ignore it. current angle(%d) is one of available angles.", cur_tz_angle);
+        return EINA_FALSE;
+     }
+
+   /* for clients supporting landscape mode only */
+   if (!(rot->available_angles & TIZEN_ROTATION_ANGLE_0) &&
+       !(rot->available_angles & TIZEN_ROTATION_ANGLE_180))
+     {
+        enum tizen_rotation_angle tz_angle = 0;
+        uint32_t serial;
+        Eina_List *l;
+        struct wl_resource *res;
+
+        if (rot->available_angles & TIZEN_ROTATION_ANGLE_90)
+          tz_angle = TIZEN_ROTATION_ANGLE_90;
+        else if (rot->available_angles & TIZEN_ROTATION_ANGLE_270)
+          tz_angle = TIZEN_ROTATION_ANGLE_270;
+        else
+          {
+             ERR("What's this impossible angle?? : %d", rot->available_angles);
+          }
+
+        if (tz_angle)
+          {
+             /* if the client requests a window rotation with the same value as the current angle, just ignore it. */
+             if ((ec->first_mapped) &&
+                 (ec->e.state.rot.ang.curr == TIZEN_ROTATION_ANGLE_TO_INT(tz_angle)))
+               {
+                  EDBG(ec, "Ignore it. given angle %d is same as the current angle for landscape only app.",
+                       tz_angle);
+                  return EINA_FALSE;
+               }
+
+             serial = wl_display_next_serial(e_comp_wl->wl.disp);
+
+             rot->angle_change_done = EINA_FALSE;
+             rot->prev_angle = rot->cur_angle;
+             rot->cur_angle = tz_angle;
+             rot->serial = serial;
+
+             EDBG(ec, "Send Change Rotation: angle %d for redering preparation of landscape only app. mapped:%d serial:%u",
+                  tz_angle, ec->first_mapped, serial);
+
+             ec->e.state.rot.ang.next = TIZEN_ROTATION_ANGLE_TO_INT(tz_angle);
+
+             EINA_LIST_FOREACH(rot->rotation_list, l, res)
+               {
+                  tizen_rotation_send_angle_change(res, tz_angle, serial);
+               }
+             return EINA_TRUE;
+          }
+     }
+   return EINA_FALSE;
+}
+
 static void
 _e_tizen_rotation_send_angle_change(E_Client *ec, int angle)
 {
@@ -2393,6 +2456,8 @@ _rot_hook_eval_fetch(void *d EINA_UNUSED, E_Client *ec)
 {
    Policy_Ext_Rotation *rot;
 
+   Eina_Bool early_angle_change = EINA_FALSE;
+
    if (!ec) return;
 
    rot = eina_hash_find(rot_hash, &ec);
@@ -2435,6 +2500,8 @@ _rot_hook_eval_fetch(void *d EINA_UNUSED, E_Client *ec)
         EDBG(ec, "Fetch Preferred: preferred (prev %d cur %d)",
             _prev_preferred_rot, ec->e.state.rot.preferred_rot);
 
+         early_angle_change = _rot_eval_fetch_preferred_send_angle_change(rot);
+
         ec->e.fetch.rot.preferred_rot = 0;
      }
    if (ec->e.fetch.rot.available_rots)
@@ -2543,11 +2610,19 @@ _rot_hook_eval_fetch(void *d EINA_UNUSED, E_Client *ec)
 
         if (diff) ec->e.fetch.rot.need_rotation = EINA_TRUE;
         ec->e.fetch.rot.available_rots = 0;
+
+         // after preferred calc., if there were no early event, check available angle again
+         if (!early_angle_change)
+           early_angle_change = _rot_eval_fetch_available_send_angle_change(rot);
      }
 end_fetch_rot:
 
    rot->hint_fetch = 1;
-   if ((ec->new_client) && (ec->e.state.rot.pending_show))
+   if (early_angle_change)
+     {
+        EDBG(ec, "Send angle_change early for ec %x, Wait ack and next surface commit after ack", e_client_util_win_get(ec));
+     }
+   else if ((ec->new_client) && (ec->e.state.rot.pending_show))
      {
         ec->e.state.rot.pending_show = 0;
         evas_object_show(ec->frame);