rotation: modify code to handle the angle between windows which have exclusive angle 22/122822/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Mon, 3 Apr 2017 12:54:34 +0000 (21:54 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Mon, 3 Apr 2017 12:54:34 +0000 (21:54 +0900)
We changed code to maintain the window angle if the intersection angle is not exist between visible windows.
For example, top window is alpha and supports preferred angle 0, and its below window supports 90,270 angles.
In this case, top window is shown on 0 angle and below window maintains its current angle.

Change-Id: I8323229315d69c7a20778087f5ef37d778df8e9b

src/rotation/e_mod_rotation_wl.c

index 53749ce..5e7005c 100644 (file)
@@ -945,8 +945,7 @@ _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclud
 {
    E_Client *ec, *bg_ec = NULL;
    Eina_List *target_list = NULL, *l, *ll;
-   int i, angle;
-   int cur_angle;
+   int angle, cur_angle, top_win_angle;
    Eina_Bool can_rotate = EINA_TRUE, ret = EINA_FALSE;
 
    TRACE_DS_BEGIN(CLIENT ROTATION ZONE SET);
@@ -956,6 +955,8 @@ _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclud
    else
      cur_angle = zone->rot.curr;
 
+   top_win_angle = -1;
+
    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,
@@ -1109,6 +1110,18 @@ _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclud
              can_rotate = EINA_FALSE;
              break;
           }
+        else
+          {
+             if (top_win_angle == -1)
+               {
+                  if (e_policy_client_is_keyboard(ec) ||
+                      e_policy_client_is_keyboard_sub(ec))
+                    continue;
+
+                  EDBG(ec, "Set top_win_angle: %d", angle);
+                  top_win_angle = angle;
+               }
+          }
      }
 
    if (!can_rotate)
@@ -1122,6 +1135,18 @@ _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclud
                   can_rotate = EINA_FALSE;
                   break;
                }
+             else
+               {
+                  if (top_win_angle == -1)
+                    {
+                       if (e_policy_client_is_keyboard(ec) ||
+                           e_policy_client_is_keyboard_sub(ec))
+                         continue;
+
+                       EDBG(ec, "Set top_win_angle: %d", angle);
+                       top_win_angle = angle;
+                    }
+               }
           }
      }
    else
@@ -1135,38 +1160,27 @@ _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclud
         /* support more than one client with fixed angle value */
         if (eina_list_count(target_list) > 0)
           {
-             Eina_Bool res, first_ec = EINA_TRUE;
-             int zone_act_angle = angle, ang;
+             Eina_Bool res;
 
-             EINA_LIST_FOREACH_SAFE(target_list, l, ll, ec)
+             if (top_win_angle == -1)
                {
-                  for (i = 0; i < 4; i++)
-                    {
-                       /* start with given angle */
-                       ang = (angle + (i * 90)) % 360;
+                  DBG("Set top_win_angle: %d", angle);
+                  top_win_angle = cur_angle;
+               }
 
-                       EDBG(ec, "Attempt to rotate client with given angle %d", ang);
+             angle = top_win_angle;
 
-                       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);
-                         }
+             EINA_LIST_FOREACH_SAFE(target_list, l, ll, ec)
+               {
+                  EDBG(ec, "Attempt to rotate client with given angle %d", top_win_angle);
+                  if (e_client_rotation_is_available(ec, top_win_angle))
+                    {
+                       res = e_client_rotation_set(ec, top_win_angle);
+                       if (!res) ret = EINA_FALSE;
+                    }
+                  else
+                    {
+                       EDBG(ec, "Failed to set given angle %d, Keep current angle %d", top_win_angle, ec->e.state.rot.ang.curr);
                     }
                }
 
@@ -1175,7 +1189,7 @@ _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclud
                   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);
+                       res = e_client_rotation_set(ec, top_win_angle);
                        if (!res) ret = EINA_FALSE;
                     }
                }