Unify ecore_evas resize code across both shm and egl engines.
authorChris Michael <cp.michael@samsung.com>
Fri, 15 Nov 2013 08:11:09 +0000 (08:11 +0000)
committerChris Michael <cp.michael@samsung.com>
Fri, 15 Nov 2013 08:11:09 +0000 (08:11 +0000)
This reduces code duplication for ecore_evas resize routines inside
wayland engines by using a common _ecore_evas_wl_common_resize
function as the resize code for both engines was the same anyway.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c

index d4fac80..53bc074 100644 (file)
@@ -204,30 +204,6 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_
    ee->prop.maximized = ecore_wl_window_maximized_get(wdata->win);
    ee->prop.fullscreen = ecore_wl_window_fullscreen_get(wdata->win);
 
-   if ((prev_max != ee->prop.maximized) ||
-       (prev_full != ee->prop.fullscreen))
-     {
-        _ecore_evas_wl_common_state_update(ee);
-
-        if (prev_full != ee->prop.fullscreen)
-          _ecore_evas_wl_common_border_update(ee);
-     }
-
-   if (ee->prop.fullscreen)
-     {
-        _ecore_evas_wl_common_move(ee, ev->x, ev->y);
-        ee->engine.func->fn_resize(ee, ev->w, ev->h);
-
-        return ECORE_CALLBACK_PASS_ON;
-     }
-
-   if ((ee->x != ev->x) || (ee->y != ev->y))
-     {
-        ee->req.x = ev->x;
-        ee->req.y = ev->y;
-        if (ee->func.fn_move) ee->func.fn_move(ee);
-     }
-
    nw = ev->w;
    nh = ev->h;
 
@@ -238,50 +214,40 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_
         evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
         if ((ee->rotation == 90) || (ee->rotation == 270))
           {
-             if (!ee->prop.maximized) nw = ev->w - fh;
+             nw = ev->w - fh;
              nh = ev->h - fw;
           }
         else
           {
-             if (!ee->prop.maximized) nw = ev->w - fw;
+             nw = ev->w - fw;
              nh = ev->h - fh;
           }
      }
 
-   if (ee->prop.min.w > nw) nw = ee->prop.min.w;
-   else if (nw > ee->prop.max.w) nw = ee->prop.max.w;
-   if (ee->prop.min.h > nh) nh = ee->prop.min.h;
-   else if (nh > ee->prop.max.h) nh = ee->prop.max.h;
+   if (prev_full != ee->prop.fullscreen)
+     _ecore_evas_wl_common_border_update(ee);
 
-   if ((ee->w != nw) || (ee->h != nh))
+   if (ee->prop.fullscreen)
      {
-        ee->req.w = nw;
-        ee->req.h = nh;
-        ee->w = nw;
-        ee->h = nh;
-        if (ee->func.fn_resize) ee->func.fn_resize(ee);
-
-        if ((ee->rotation == 90) || (ee->rotation == 270))
-          {
-             evas_output_size_set(ee->evas, ev->h, ev->w);
-             evas_output_viewport_set(ee->evas, 0, 0, ev->h, ev->w);
-          }
-        else
-          {
-             evas_output_size_set(ee->evas, ev->w, ev->h);
-             evas_output_viewport_set(ee->evas, 0, 0, ev->w, ev->h);
-          }
+        _ecore_evas_wl_common_move(ee, ev->x, ev->y);
+        _ecore_evas_wl_common_resize(ee, nw, nh);
 
-        if (wdata->frame)
-          evas_object_resize(wdata->frame, ev->w, ev->h);
+        if (prev_full != ee->prop.fullscreen)
+          _ecore_evas_wl_common_state_update(ee);
 
-        if (wdata->win)
-          {
-             _ecore_evas_wayland_resize_edge_set(ee, ev->edges);
-             ecore_wl_window_update_size(wdata->win, ev->w, ev->h);
-          }
+        return ECORE_CALLBACK_PASS_ON;
      }
 
+   if ((ee->x != ev->x) || (ee->y != ev->y))
+     _ecore_evas_wl_common_move(ee, ev->x, ev->y);
+
+   if ((ee->w != ev->w) || (ee->h != ev->h))
+     _ecore_evas_wl_common_resize(ee, nw, nh);
+
+   if ((prev_max != ee->prop.maximized) ||
+       (prev_full != ee->prop.fullscreen))
+     _ecore_evas_wl_common_state_update(ee);
+
    return ECORE_CALLBACK_PASS_ON;
 }
 
@@ -533,6 +499,8 @@ void
 _ecore_evas_wl_common_resize(Ecore_Evas *ee, int w, int h)
 {
    Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
+   int orig_w, orig_h;
+   int ow, oh;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
@@ -541,6 +509,8 @@ _ecore_evas_wl_common_resize(Ecore_Evas *ee, int w, int h)
 
    ee->req.w = w;
    ee->req.h = h;
+   orig_w = w;
+   orig_h = h;
 
    if (!ee->prop.fullscreen)
      {
@@ -551,15 +521,27 @@ _ecore_evas_wl_common_resize(Ecore_Evas *ee, int w, int h)
         if (ee->prop.min.h > h) h = ee->prop.min.h;
         else if (h > ee->prop.max.h) h = ee->prop.max.h;
 
+        orig_w = w;
+        orig_h = h;
+
         evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
-        w += fw;
-        h += fh;
+        if ((ee->rotation == 90) || (ee->rotation == 270))
+          {
+             w += fh;
+             h += fw;
+          }
+        else
+          {
+             w += fw;
+             h += fh;
+          }
      }
 
-   if ((ee->w != w) || (ee->h != h))
+   evas_output_size_get(ee->evas, &ow, &oh);
+   if ((ow != w) || (oh != h))
      {
-        ee->w = w;
-        ee->h = h;
+        ee->w = orig_w;
+        ee->h = orig_h;
 
         if ((ee->rotation == 90) || (ee->rotation == 270))
           {
@@ -583,6 +565,11 @@ _ecore_evas_wl_common_resize(Ecore_Evas *ee, int w, int h)
 
         if (wdata->frame)
           evas_object_resize(wdata->frame, w, h);
+
+        /* if (wdata->win) */
+        /*   ecore_wl_window_update_size(wdata->win, w, h); */
+
+        if (ee->func.fn_resize) ee->func.fn_resize(ee);
      }
 }
 
@@ -1118,7 +1105,7 @@ _ecore_evas_wl_common_maximized_set(Ecore_Evas *ee, int max)
    if (ee->prop.maximized == max) return;
    wdata = ee->engine.data;
    ecore_wl_window_maximized_set(wdata->win, max);
-   _ecore_evas_wl_common_state_update(ee);
+//   _ecore_evas_wl_common_state_update(ee);
 }
 
 void
@@ -1132,7 +1119,7 @@ _ecore_evas_wl_common_fullscreen_set(Ecore_Evas *ee, int full)
    if (ee->prop.fullscreen == full) return;
    wdata = ee->engine.data;
    ecore_wl_window_fullscreen_set(wdata->win, full);
-   _ecore_evas_wl_common_state_update(ee);
+//   _ecore_evas_wl_common_state_update(ee);
 }
 
 void
index 442937d..c150d6a 100644 (file)
@@ -9,7 +9,6 @@
 # include <Evas_Engine_Wayland_Egl.h>
 
 /* local function prototypes */
-static void _ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h);
 static void _ecore_evas_wl_move_resize(Ecore_Evas *ee, int x, int y, int w, int h);
 static void _ecore_evas_wl_show(Ecore_Evas *ee);
 static void _ecore_evas_wl_hide(Ecore_Evas *ee);
@@ -36,7 +35,7 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
    NULL, // post_render_set
    _ecore_evas_wl_common_move,
    NULL, // managed_move
-   _ecore_evas_wl_resize,
+   _ecore_evas_wl_common_resize,
    _ecore_evas_wl_move_resize,
    _ecore_evas_wl_rotation_set,
    NULL, // shaped_set
@@ -252,86 +251,6 @@ ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
 }
 
 static void 
-_ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h)
-{
-   Ecore_Evas_Engine_Wl_Data *wdata;
-   LOGFN(__FILE__, __LINE__, __FUNCTION__);
-   int orig_w, orig_h;
-   int ow, oh;
-
-   if (!ee) return;
-   if (w < 1) w = 1;
-   if (h < 1) h = 1;
-
-   ee->req.w = w;
-   ee->req.h = h;
-   orig_w = w;
-   orig_h = h;
-
-   wdata = ee->engine.data;
-
-   if (!ee->prop.fullscreen)
-     {
-        int fw = 0, fh = 0;
-
-        if (ee->prop.min.w > w) w = ee->prop.min.w;
-        else if (w > ee->prop.max.w) w = ee->prop.max.w;
-        if (ee->prop.min.h > h) h = ee->prop.min.h;
-        else if (h > ee->prop.max.h) h = ee->prop.max.h;
-
-        orig_w = w;
-        orig_h = h;
-
-        evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
-        if ((ee->rotation == 90) || (ee->rotation == 270))
-          {
-             w += fh;
-             h += fw;
-          }
-        else
-          {
-             w += fw;
-             h += fh;
-          }
-     }
-
-   evas_output_size_get(ee->evas, &ow, &oh);
-   if ((ow != w) || (oh != h))
-     {
-        ee->w = orig_w;
-        ee->h = orig_h;
-
-        if ((ee->rotation == 90) || (ee->rotation == 270))
-          {
-             evas_output_size_set(ee->evas, h, w);
-             evas_output_viewport_set(ee->evas, 0, 0, h, w);
-          }
-        else
-          {
-             evas_output_size_set(ee->evas, w, h);
-             evas_output_viewport_set(ee->evas, 0, 0, w, h);
-          }
-
-        if (ee->prop.avoid_damage)
-          {
-             int pdam = 0;
-
-             pdam = ecore_evas_avoid_damage_get(ee);
-             ecore_evas_avoid_damage_set(ee, 0);
-             ecore_evas_avoid_damage_set(ee, pdam);
-          }
-
-        if (wdata->frame)
-          evas_object_resize(wdata->frame, w, h);
-
-        if (wdata->win)
-          ecore_wl_window_update_size(wdata->win, w, h);
-
-        if (ee->func.fn_resize) ee->func.fn_resize(ee);
-     }
-}
-
-static void 
 _ecore_evas_wl_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
@@ -340,7 +259,7 @@ _ecore_evas_wl_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
    if ((ee->x != x) || (ee->y != y))
      _ecore_evas_wl_common_move(ee, x, y);
    if ((ee->w != w) || (ee->h != h))
-     _ecore_evas_wl_resize(ee, w, h);
+     _ecore_evas_wl_common_resize(ee, w, h);
 }
 
 static void
index cfdd33c..b453947 100644 (file)
@@ -9,7 +9,6 @@
 # include <sys/mman.h>
 
 /* local function prototypes */
-static void _ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h);
 static void _ecore_evas_wl_move_resize(Ecore_Evas *ee, int x, int y, int w, int h);
 static void _ecore_evas_wl_show(Ecore_Evas *ee);
 static void _ecore_evas_wl_hide(Ecore_Evas *ee);
@@ -36,7 +35,7 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
    NULL, // post_render_set
    _ecore_evas_wl_common_move,
    NULL, // managed_move
-   _ecore_evas_wl_resize,
+   _ecore_evas_wl_common_resize,
    _ecore_evas_wl_move_resize,
    _ecore_evas_wl_rotation_set,
    NULL, // shaped_set
@@ -245,87 +244,6 @@ ecore_evas_wayland_shm_new_internal(const char *disp_name, unsigned int parent,
 }
 
 static void 
-_ecore_evas_wl_resize(Ecore_Evas *ee, int w, int h)
-{
-   Ecore_Evas_Engine_Wl_Data *wdata;
-   int orig_w, orig_h;
-   int ow, oh;
-
-   LOGFN(__FILE__, __LINE__, __FUNCTION__);
-
-   if (!ee) return;
-   if (w < 1) w = 1;
-   if (h < 1) h = 1;
-
-   ee->req.w = w;
-   ee->req.h = h;
-   orig_w = w;
-   orig_h = h;
-
-   wdata = ee->engine.data;
-
-   if (!ee->prop.fullscreen)
-     {
-        int fw = 0, fh = 0;
-
-        if (ee->prop.min.w > w) w = ee->prop.min.w;
-        else if (w > ee->prop.max.w) w = ee->prop.max.w;
-        if (ee->prop.min.h > h) h = ee->prop.min.h;
-        else if (h > ee->prop.max.h) h = ee->prop.max.h;
-
-        orig_w = w;
-        orig_h = h;
-
-        evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
-        if ((ee->rotation == 90) || (ee->rotation == 270))
-          {
-             w += fh;
-             h += fw;
-          }
-        else
-          {
-             w += fw;
-             h += fh;
-          }
-     }
-
-   evas_output_size_get(ee->evas, &ow, &oh);
-   if ((ow != w) || (oh != h))
-     {
-        ee->w = orig_w;
-        ee->h = orig_h;
-
-        if ((ee->rotation == 90) || (ee->rotation == 270))
-          {
-             evas_output_size_set(ee->evas, h, w);
-             evas_output_viewport_set(ee->evas, 0, 0, h, w);
-          }
-        else
-          {
-             evas_output_size_set(ee->evas, w, h);
-             evas_output_viewport_set(ee->evas, 0, 0, w, h);
-          }
-
-        if (ee->prop.avoid_damage)
-          {
-             int pdam = 0;
-
-             pdam = ecore_evas_avoid_damage_get(ee);
-             ecore_evas_avoid_damage_set(ee, 0);
-             ecore_evas_avoid_damage_set(ee, pdam);
-          }
-
-        if (wdata->frame)
-          evas_object_resize(wdata->frame, w, h);
-
-        if (wdata->win)
-          ecore_wl_window_update_size(wdata->win, w, h);
-
-        if (ee->func.fn_resize) ee->func.fn_resize(ee);
-     }
-}
-
-static void 
 _ecore_evas_wl_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
@@ -334,7 +252,7 @@ _ecore_evas_wl_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
    if ((ee->x != x) || (ee->y != y))
      _ecore_evas_wl_common_move(ee, x, y);
    if ((ee->w != w) || (ee->h != h))
-     _ecore_evas_wl_resize(ee, w, h);
+     _ecore_evas_wl_common_resize(ee, w, h);
 }
 
 static void