Resize widget buffer using supported one only
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 12 May 2015 02:11:52 +0000 (11:11 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 12 May 2015 02:18:28 +0000 (11:18 +0900)
[model] Redwood,Kiran,B3(Wearable)
[binary_type] AP
[customer] Docomo/Orange/ATT/Open
[issue#] N/A
[problem]
[cause]
[solution]
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: I0a003532ee3251cfe30611eb809850493750e09e

widget_viewer_evas/src/widget_viewer_evas.c

index 0951d4b..d94087d 100644 (file)
 
 #define DEFAULT_OVERLAY_COUNTER 2
 #define DEFAULT_OVERLAY_WAIT_TIME 1.0f
+#define RESEVED_AREA_FOR_GBAR_EFFECT 100
 
 #define WIDGET_CLASS_NAME "widget"
 
@@ -624,8 +625,8 @@ static widget_size_type_e find_size_type(struct widget_data *data, int w, int h)
 {
        int cnt = WIDGET_COUNT_OF_SIZE_TYPE;
        int i;
-       int *_w;
-       int *_h;
+       int *_w = NULL;
+       int *_h = NULL;
        widget_size_type_e type = WIDGET_SIZE_TYPE_UNKNOWN;
        int find;
        int ret_type = WIDGET_SIZE_TYPE_UNKNOWN;
@@ -667,10 +668,8 @@ static widget_size_type_e find_size_type(struct widget_data *data, int w, int h)
                }
        }
 
-       if (_w)
-               free(_w);
-       if (_h)
-               free(_h);
+       free(_w);
+       free(_h);
 
        return ret_type;
 }
@@ -695,7 +694,7 @@ static Eina_Bool effect_animator_cb(void *_data)
 
        if (data->effect_mask & EFFECT_WIDTH) {
                if (w < data->w) {
-                       if (data->w - w > 100) {
+                       if (data->w - w > RESEVED_AREA_FOR_GBAR_EFFECT) {
                                w += 20;
                                move_x = 20;
                        } else if (data->w - w > 10) {
@@ -706,7 +705,7 @@ static Eina_Bool effect_animator_cb(void *_data)
                                move_x = 1;
                        }
                } else if (w > data->w) {
-                       if (w - data->w > 100) {
+                       if (w - data->w > RESEVED_AREA_FOR_GBAR_EFFECT) {
                                w -= 20;
                                move_x = -20;
                        } else if (w - data->w > 10) {
@@ -723,7 +722,7 @@ static Eina_Bool effect_animator_cb(void *_data)
 
        if (data->effect_mask & EFFECT_HEIGHT) {
                if (h < data->h) {
-                       if (data->h - h > 100) {
+                       if (data->h - h > RESEVED_AREA_FOR_GBAR_EFFECT) {
                                h += 20;
                                move_y = 20;
                        } else if (data->h - h > 10) {
@@ -734,7 +733,7 @@ static Eina_Bool effect_animator_cb(void *_data)
                                move_y = 1;
                        }
                } else if (h > data->h) {
-                       if (h - data->h > 100) {
+                       if (h - data->h > RESEVED_AREA_FOR_GBAR_EFFECT) {
                                h -= 20;
                                move_y = -20;
                        } else if (h - data->h > 10) {
@@ -4767,13 +4766,19 @@ static void __widget_resize(Evas_Object *widget, Evas_Coord w, Evas_Coord h)
        type = find_size_type(data, w, h);
        if (type == WIDGET_SIZE_TYPE_UNKNOWN) {
                ErrPrint("Invalid size: %dx%d\n", w, h);
-               //return;
        } else if (s_info.conf.field.use_fixed_size) {
                if (widget_service_get_size(type, &w, &h) < 0) {
                        ErrPrint("Failed to get box size\n");
                }
        }
 
+       /**
+        * @note
+        * If the use_fixed_size is false, the size_type can be differ with width & height
+        * Then we should not try to resize resource_id(surface) as width & height.
+        * Just keep them their size and try to resize layout only.
+        */
+
        if (!widget_viewer_is_created_by_user(data->handle)) {
                /**
                 * Viewer should not be able to resize the box
@@ -4799,6 +4804,8 @@ static void __widget_resize(Evas_Object *widget, Evas_Coord w, Evas_Coord h)
                data->size_type = type;
        }
 
+       DbgPrint("Request size change: %dx%d [0x%X]\n", w, h, data->size_type);
+
        if (data->is.field.faulted) {
                evas_object_resize(data->widget_layout, data->widget_width, data->widget_height);
                ErrPrint("Faulted widget, skip resizing (%s)\n", data->widget_id);
@@ -4809,12 +4816,15 @@ static void __widget_resize(Evas_Object *widget, Evas_Coord w, Evas_Coord h)
                struct acquire_data acquire_data = {
                        .data = data,
                };
+
                DbgPrint("Create new handle: %dx%d, (%s, %s), %s/%s\n", data->widget_width, data->widget_height,
                                data->widget_id, data->content,
                                data->cluster, data->category);
+
                if (widget_viewer_activate_faulted_widget(data->widget_id, NULL, NULL) < 0) {
                        ErrPrint("Activate: %s\n", data->widget_id);
                }
+
                data->is.field.created = 0;
                data->is.field.send_delete = 1;
                update_widget_geometry(&acquire_data);
@@ -4833,15 +4843,13 @@ static void __widget_resize(Evas_Object *widget, Evas_Coord w, Evas_Coord h)
                DbgPrint("Added handle: %p (%p)\n", data->handle, data);
                widget_viewer_set_data(data->handle, widget);
                __widget_overlay_loading(data);
-               widget_service_get_need_of_touch_effect(data->widget_id, type, (bool*)&need_of_touch_effect);
+               widget_service_get_need_of_touch_effect(data->widget_id, type, (bool *)&need_of_touch_effect);
                data->is.field.touch_effect = need_of_touch_effect;
-               widget_service_get_need_of_mouse_event(data->widget_id, type, (bool*)&need_of_mouse_event);
+               widget_service_get_need_of_mouse_event(data->widget_id, type, (bool *)&need_of_mouse_event);
                data->is.field.mouse_event = need_of_mouse_event;
        } else {
                int ret;
 
-               DbgPrint("Resize to %dx%d\n", w, h);
-
                if (type > 0 && type != WIDGET_SIZE_TYPE_UNKNOWN) {
                        ret = widget_viewer_resize_widget(data->handle, type, __widget_resize_cb, widget_ref(data));
                } else {
@@ -4856,9 +4864,9 @@ static void __widget_resize(Evas_Object *widget, Evas_Coord w, Evas_Coord h)
                        widget_unref(data);
                } else if (ret == WIDGET_ERROR_NONE) {
                        DbgPrint("Resize request is successfully sent\n");
-                       widget_service_get_need_of_touch_effect(data->widget_id, type, (bool*)&need_of_touch_effect);
+                       widget_service_get_need_of_touch_effect(data->widget_id, type, (bool *)&need_of_touch_effect);
                        data->is.field.touch_effect = need_of_touch_effect;
-                       widget_service_get_need_of_mouse_event(data->widget_id, type, (bool*)&need_of_mouse_event);
+                       widget_service_get_need_of_mouse_event(data->widget_id, type, (bool *)&need_of_mouse_event);
                        data->is.field.mouse_event = need_of_mouse_event;
                } else {
                        widget_unref(data);
@@ -5043,7 +5051,7 @@ static void update_widget_geometry(struct acquire_data *acquire_data)
        } else {
                stage_w = widget_w;
                if (s_info.conf.field.support_gbar) {
-                       stage_h = widget_h + 100; /* Reserve 100 px for effect */
+                       stage_h = widget_h + RESEVED_AREA_FOR_GBAR_EFFECT; /* Reserve 100 px for effect */
                } else {
                        stage_h = widget_h;
                }
@@ -5189,8 +5197,17 @@ static void __widget_event_widget_updated(struct widget_data *data)
                return;
        }
 
-       w = data->widget_width;
-       h = data->widget_height;
+       /**
+        * @note
+        * We should not use this widget_width and widget_height
+        * It is set'd by user but the resource_id buffer should be resized by size_type.
+        * Even if the script or text or image can be resized to given size,.
+        * We should handles them as resource_id to make the consistent behaviour.
+        */
+       widget_service_get_size(type, &w, &h);
+       if (w != data->widget_width || h != data->widget_height) {
+               DbgPrint("Pixel and Type are differ. use type [%dx%d] - [%dx%d]\n", w, h, data->widget_width, data->widget_height);
+       }
 
        widget_viewer_get_type(data->handle, 0, &widget_type);