rotation: support more than one client with fixed angle value which is set by using... 24/119424/2
authorGwanglim Lee <gl77.lee@samsung.com>
Fri, 17 Mar 2017 03:10:09 +0000 (12:10 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Fri, 17 Mar 2017 03:21:19 +0000 (12:21 +0900)
Change-Id: Iaa660daa3f0fbcbc6ba076ab399f5591167f5eee

src/rotation/e_mod_rotation_wl.c

index 650f5cd..c7ee70b 100644 (file)
@@ -891,20 +891,26 @@ static Eina_Bool
 _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclude_ec)
 {
    E_Client *ec, *bg_ec = NULL;
-   Eina_List *target_list = NULL, *l;
+   Eina_List *target_list = NULL, *l, *ll;
    int i, angle;
    int cur_angle;
    Eina_Bool can_rotate = EINA_TRUE, ret = EINA_FALSE;
 
    TRACE_DS_BEGIN(CLIENT ROTATION ZONE SET);
 
-   DBG("<<< Try to set zone rotation");
-
    if (zone->rot.unknown_state)
      cur_angle = zone->rot.act;
    else
      cur_angle = zone->rot.curr;
 
+   DBG("<<< Try to set zone rotation | fg_ec '%s'(%p) cur_angle:%d zone(unknown_state:%d act:%d curr:%d)",
+       fg_ec ? fg_ec->icccm.name : "",
+       fg_ec,
+       cur_angle,
+       zone->rot.unknown_state,
+       zone->rot.act,
+       zone->rot.curr);
+
    E_CLIENT_REVERSE_FOREACH(ec)
      {
         if (ec->zone != zone) continue;
@@ -1035,7 +1041,7 @@ _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclud
 
    if (!target_list || (target_list && eina_list_count(target_list) == 0))
      {
-        DBG("Duna Failed to set rotation with zone: target_list is empty. angle: %d", angle);
+        DBG("Failed to set rotation with zone: target_list is empty. angle: %d", angle);
         if (fg_ec)
           angle = _e_client_rotation_curr_next_get(fg_ec);
         can_rotate = EINA_FALSE;
@@ -1073,30 +1079,56 @@ _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclud
 
    if (!can_rotate)
      {
-        for (i = 0; i < 360; i += 90)
+        /* support more than one client with fixed angle value */
+        if (eina_list_count(target_list) > 0)
           {
-             if ((i == cur_angle) || (i == angle))
-               continue;
+             Eina_Bool res, first_ec = EINA_TRUE;
+             int zone_act_angle = angle, ang;
 
-             can_rotate = EINA_TRUE;
-
-             EINA_LIST_FOREACH(target_list, l, ec)
+             EINA_LIST_FOREACH_SAFE(target_list, l, ll, ec)
                {
-                  if (!e_client_rotation_is_available(ec, i))
+                  for (i = 0; i < 4; i++)
                     {
-                       EDBG(ec, "Failed to set zone rotation: not able to rotate given angle %d", i);
-                       can_rotate = EINA_FALSE;
-                       break;
+                       /* start with given angle */
+                       ang = (angle + (i * 90)) % 360;
+
+                       EDBG(ec, "Attempt to rotate client with given angle %d", ang);
+
+                       if (e_client_rotation_is_available(ec, ang))
+                         {
+                            res = e_client_rotation_set(ec, ang);
+                            if (!res) ret = EINA_FALSE;
+
+                            if (first_ec)
+                              {
+                                 /* change angle of zone according to top most ec */
+                                 EDBG(ec, "Change zoen angle %d -> %d", zone_act_angle, ang);
+                                 zone_act_angle = ang;
+                                 first_ec = EINA_FALSE;
+                              }
+
+                            target_list = eina_list_remove_list(target_list, l);
+                            break;
+                         }
+                       else
+                         {
+                            EDBG(ec, "Failed to set with exist client: not able to rotate given angle %d", ang);
+                         }
                     }
                }
 
-             if (can_rotate == EINA_TRUE)
+             EINA_LIST_FOREACH(rot.force_update_list, l, ec)
                {
-                  angle = i;
-                  DBG("Set rotation of zone according to common angle of clients: %d", angle);
-                  break;
+                  if (!eina_list_data_find(target_list, ec))
+                    {
+                       EDBG(ec, "Rotate ec of force_update_list '%s'(%p)", ec->icccm.name, ec);
+                       res = e_client_rotation_set(ec, zone_act_angle);
+                       if (!res) ret = EINA_FALSE;
+                    }
                }
           }
+
+        goto end;
      }
    else
      {