ecore_evas: fix calculating window with rotation. 03/280303/5
authorHosang Kim <hosang12.kim@samsung.com>
Fri, 26 Aug 2022 10:18:37 +0000 (19:18 +0900)
committerkim hosang <hosang12.kim@samsung.com>
Mon, 29 Aug 2022 02:15:28 +0000 (02:15 +0000)
When border is enabled, between ecore_evas window size and ecore_wl2 window size are different.
And window size is added or subtracted with border size according to rotation angle.

Change-Id: Icbbb5da354371c610058ef2de165431197b1158c

src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c

index de233e7..0ce5be9 100644 (file)
@@ -555,7 +555,7 @@ _ecore_evas_wl_common_resize(Ecore_Evas *ee, int w, int h)
 
         if (ee->func.fn_resize) ee->func.fn_resize(ee);
      }
-   ecore_wl2_window_geometry_set(wdata->win, ee->x, ee->y, ee->w, ee->h);
+   ecore_wl2_window_geometry_set(wdata->win, ee->x, ee->y, w, h);
 }
 
 static void
@@ -611,6 +611,23 @@ _ecore_evas_wl_common_wm_rot_manual_rotation_done_timeout(void *data)
    return ECORE_CALLBACK_CANCEL;
 }
 
+void _ecore_evas_framespace_get(Ecore_Evas *ee, int *fw, int *fh)
+{
+   int ww, wh, sw, sh, framew, frameh, cw, ch;
+
+   ecore_evas_geometry_get(ee, NULL, NULL, &ww, &wh);
+
+   sw = ee->shadow.l + ee->shadow.r;
+   sh = ee->shadow.t + ee->shadow.b;
+   evas_output_framespace_get(ee->evas, NULL, NULL, &framew, &frameh);
+
+   cw = ww - (framew - sw);
+   ch = wh - (frameh - sh);
+
+   if (fw) *fw = ww - cw;
+   if (fh) *fh = wh - ch;
+}
+
 static void
 _ecore_evas_wl_common_wm_rot_manual_rotation_done_timeout_update(Ecore_Evas *ee)
 {
@@ -627,9 +644,7 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_
    Ecore_Evas *ee;
    Ecore_Evas_Engine_Wl_Data *wdata;
    Ecore_Wl2_Event_Window_Configure *ev;
-   int nw = 0, nh = 0, fw, fh, pfw, pfh, sw, sh, contentw, contenth;
-   int ww, wh;
-   int framew, frameh;
+   int nw = 0, nh = 0, fw, fh, pfw, pfh;
    Eina_Bool active, prev_max, prev_full, state_change = EINA_FALSE;
 
    // TIZEN_ONLY(20160630)
@@ -683,15 +698,10 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_
    ecore_wl2_window_geometry_get(wdata->win, &nx, &ny, NULL, NULL);
 //
 
-   ecore_evas_geometry_get(ee, NULL, NULL, &ww, &wh);
+   _ecore_evas_framespace_get(ee, &fw, &fh);
 
-   sw = ee->shadow.l + ee->shadow.r;
-   sh = ee->shadow.t + ee->shadow.b;
-   evas_output_framespace_get(ee->evas, NULL, NULL, &framew, &frameh);
-   contentw = ww - (framew - sw);
-   contenth = wh - (frameh - sh);
-   pfw = fw = ww - contentw;
-   pfh = fh = wh - contenth;
+   pfw = fw;
+   pfh = fh;
 
    if ((prev_max != ee->prop.maximized) ||
        (prev_full != ee->prop.fullscreen) ||
@@ -699,13 +709,7 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_
      {
         state_change = EINA_TRUE;
         _ecore_evas_wl_common_state_update(ee);
-        sw = ee->shadow.l + ee->shadow.r;
-        sh = ee->shadow.t + ee->shadow.b;
-        evas_output_framespace_get(ee->evas, NULL, NULL, &framew, &frameh);
-        contentw = ww - (framew - sw);
-        contenth = wh - (frameh - sh);
-        fw = ww - contentw;
-        fh = wh - contenth;
+        _ecore_evas_framespace_get(ee, &fw, &fh);
      }
    if ((!nw) && (!nh))
      {
@@ -724,8 +728,16 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_
 
    if (!ee->prop.borderless)
      {
-        nw -= fw;
-        nh -= fh;
+        if (ECORE_EVAS_PORTRAIT(ee))
+          {
+             nw -= fw;
+             nh -= fh;
+          }
+        else
+          {
+             nw -= fh;
+             nh -= fw;
+          }
      }
 
    if (ee->prop.fullscreen || (ee->req.w != nw) || (ee->req.h != nh))
@@ -923,6 +935,7 @@ _ecore_evas_wl_common_cb_window_rotate(void *data EINA_UNUSED, int type EINA_UNU
    Ecore_Evas *ee;
    Ecore_Wl2_Event_Window_Rotation *ev;
    Ecore_Evas_Engine_Wl_Data *wdata;
+   int fw, fh, nw ,nh;
 
    LOGFN;
 
@@ -950,12 +963,33 @@ _ecore_evas_wl_common_cb_window_rotate(void *data EINA_UNUSED, int type EINA_UNU
    wdata->wm_rot.request = 1;
    wdata->wm_rot.done = 0;
 
+   nw = ev->w;
+   nh = ev->h;
+
+   _ecore_evas_framespace_get(ee, &fw, &fh);
+
+   if (!ee->prop.borderless)
+     {
+        if (ECORE_EVAS_PORTRAIT(ee))
+          {
+             nw -= fw;
+             nh -= fh;
+          }
+        else
+          {
+             nw -= fh;
+             nh -= fw;
+          }
+     }
+
    /* TIZEN_ONLY: if the width or height are zero, it means the client should
       decide its own window dimension. */
-   if (ev->w > 0 && ev->h > 0)
+   if (nw > 0 && nh > 0)
      {
-        if ((ee->w != ev->w) || (ee->h != ev->h))
-          _ecore_evas_wl_common_resize(ee, ev->w , ev->h);
+        if ((ee->w != nw) || (ee->h != nh))
+          {
+             _ecore_evas_wl_common_resize(ee, nw, nh);
+          }
      }
 
    if (ee->prop.wm_rot.manual_mode.set)
@@ -3038,6 +3072,7 @@ _ecore_evas_wl_common_show(Ecore_Evas *ee)
 
    if (wdata->win)
      {
+        int w = ee->w, h = ee->h;
         int fw, fh;
 
         if (wdata->win->xdg_set_min_size && wdata->win->xdg_toplevel && wdata->win->pending.min)
@@ -3066,7 +3101,20 @@ _ecore_evas_wl_common_show(Ecore_Evas *ee)
 /*
         ecore_wl2_window_geometry_set(wdata->win, 0, 0, ee->w, ee->h);
 */
-        ecore_wl2_window_geometry_set(wdata->win, ee->x, ee->y, ee->w, ee->h);
+        if (!ee->prop.fullscreen) {
+          if (ECORE_EVAS_PORTRAIT(ee))
+            {
+               w += fw;
+               h += fh;
+            }
+          else
+            {
+               w += fh;
+               h += fw;
+            }
+        }
+
+        ecore_wl2_window_geometry_set(wdata->win, ee->x, ee->y, w, h);
 //
         ecore_wl2_window_show(wdata->win);
         ecore_wl2_window_alpha_set(wdata->win, ee->alpha);