rotation: add code to check preferred angle while handling rotation 53/123953/2
authorDoyoun Kang <doyoun.kang@samsung.com>
Sat, 8 Apr 2017 09:33:22 +0000 (18:33 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Sat, 8 Apr 2017 09:41:10 +0000 (18:41 +0900)
There was a bug that the window doesn't rotate when it set the preferred angle which is not same to current angle.

Change-Id: Ie34f35a90920ec9ae2f177ab78af168ce124be5b

src/rotation/e_mod_rotation_wl.c

index 5e7005c..640f996 100644 (file)
@@ -1161,11 +1161,42 @@ _e_client_rotation_zone_set(E_Zone *zone, E_Client *include_ec, E_Client *exclud
         if (eina_list_count(target_list) > 0)
           {
              Eina_Bool res;
+             int i, ang;
 
              if (top_win_angle == -1)
                {
-                  DBG("Set top_win_angle: %d", angle);
-                  top_win_angle = cur_angle;
+                  EINA_LIST_FOREACH_SAFE(target_list, l, ll, ec)
+                    {
+                       DBG("Find top most window angle");
+                       // 1. check preferred
+                       if (ec->e.state.rot.preferred_rot != -1)
+                         {
+                            EDBG(ec, "Set top_win_angle(preferred angle): %d", ec->e.state.rot.preferred_rot);
+                            top_win_angle = ec->e.state.rot.preferred_rot;
+                            break;
+                         }
+
+                       // 2. check available angle
+                       for (i = 0; i < 4; i++)
+                         {
+                            ang = (cur_angle + (i * 90)) % 360;
+                            if (e_client_rotation_is_available(ec, ang))
+                              {
+                                 EDBG(ec, "Set top_win_angle: %d", ang);
+                                 top_win_angle = ang;
+                                 break;
+                              }
+                         }
+
+                       if (top_win_angle == -1)
+                         {
+                            // 3. couldn't find available angle
+                            EDBG(ec, "Cannot find any available angle. Set top_win_angle to 0");
+                            top_win_angle = 0;
+                         }
+
+                       break;
+                    }
                }
 
              angle = top_win_angle;