rotation: add a smart placement feature for rotation 74/278874/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Wed, 27 Jul 2022 08:18:28 +0000 (17:18 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Wed, 27 Jul 2022 08:18:28 +0000 (17:18 +0900)
Change-Id: I1985360b3de7c6a2d27e343cfc284645d67d51cc

src/rotation/e_mod_rotation_wl.c

index d106660..4b73eee 100644 (file)
@@ -622,6 +622,98 @@ _e_tizen_rotation_angle_change(Policy_Ext_Rotation *rot)
 }
 
 static void
+_e_tizen_rotation_smart_placement_apply(E_Client *ec)
+{
+   int angle = 0;
+   int x, y, w, h;
+   int new_x, new_y;
+   int x1, y1, x2, y2;
+   int zx, zy, zw, zh;
+
+   angle = ec->zone->rot.curr;
+
+   e_client_geometry_get(ec, &x, &y, &w, &h);
+   new_x = x;
+   new_y = y;
+
+   x1 = x;
+   x2 = x+w;
+   y1 = y;
+   y2 = y+h;
+
+   zx = ec->zone->x;
+   zy = ec->zone->y;
+   zw = ec->zone->w;
+   zh = ec->zone->h;
+
+   // calculate x position
+   if (x1 < 0)
+     {
+        if (w > zw)
+          {
+             if (angle == 270)
+               new_x = -w;
+             else
+               new_x = 0;
+          }
+        else
+          new_x = 0;
+     }
+   else if (x2 > zx + zw)
+     {
+        if (w > zw)
+          {
+             if (angle == 270\r)
+               new_x = -w;
+             else
+               new_x = 0;
+          }
+        else
+          new_x = zx + zw - w;
+     }
+   else
+     {
+        new_x = x;
+     }
+
+   // calculate y position
+   if (y1 < 0)
+     {
+        if (h > zh)
+          {
+             if (angle == 180)
+               new_y = -h;
+             else
+               new_y = 0;
+          }
+        else
+          new_y = 0;
+     }
+   else if (y2 > zy + zh)
+     {
+        if (h > zh)
+          {
+             if (angle == 180)
+               new_y = -h;
+             else
+               new_y = 0;
+          }
+        else
+          new_y = zy + zh - h;
+     }
+   else
+     {
+        new_y = y;
+     }
+
+   if ((x != new_x) || (y != new_y))
+     {
+        ELOGF("ROTATION", "APPLY placement policy. old(%d,%d) -> new(%d,%d), angle:%d", ec, x, y, new_x, new_y, angle);
+        e_client_util_move_without_frame(ec, new_x, new_y);
+     }
+}
+
+static void
 _e_tizen_rotation_ack_angle_change_cb(struct wl_client *client,
                                       struct wl_resource *resource,
                                       uint32_t serial)
@@ -2417,6 +2509,8 @@ _e_client_rotation_wait_update_clear(E_Client *ec)
      E_FREE_FUNC(rot->show_grab, e_policy_visibility_client_grab_release);
 
    rot->wait_update = EINA_FALSE;
+
+   _e_tizen_rotation_smart_placement_apply(ec);
 }
 
 static Eina_Bool