Restart faulted widget when it is at the visible area 09/149809/6
authorJunghoon Park <jh9216.park@samsung.com>
Wed, 13 Sep 2017 06:49:47 +0000 (15:49 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Wed, 13 Sep 2017 11:23:49 +0000 (20:23 +0900)
Change-Id: I906f6f822e02fff5a6cc1de84e8ace37c6547c91
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
widget_viewer_evas/src/widget_viewer_evas.c

index d32ce19..2e9defc 100644 (file)
@@ -22,6 +22,7 @@
 #include <errno.h>
 #include <glib.h>
 
+#include <Ecore_Wayland.h>
 #include <Elementary.h>
 #include <Ecore.h>
 #include <Ecore_Evas.h>
@@ -43,7 +44,6 @@
 #include <screen_connector_toolkit_evas.h>
 #include <app_control_internal.h>
 
-
 #if defined(LOG_TAG)
 #undef LOG_TAG
 #endif
@@ -1038,6 +1038,56 @@ static void resize_cb(void *data, Evas *e, Evas_Object *layout, void *event_info
        }
 }
 
+static bool __obj_is_visible(Evas_Object *layout)
+{
+       int x, y, w, h;
+       Ecore_Wl_Window *window = NULL;
+       int window_x, window_y, window_w, window_h;
+       int rotation;
+
+       window = elm_win_wl_window_get(s_info.win);
+       ecore_wl_window_geometry_get(window, &window_x, &window_y, &window_w, &window_h);
+       evas_object_geometry_get(layout, &x, &y, &w, &h);
+       rotation = ecore_wl_window_rotation_get(window);
+
+       if (x >= 0 && x < window_w &&
+                       y >= 0 && y < window_h &&
+                       (rotation == 0 || rotation == 180)) {
+               DbgPrint("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d",
+                               x, y, w, h, window_w, window_h, rotation);
+               return true;
+       } else if (x >= 0 && x < window_h &&
+                       y >= 0 && y < window_w &&
+                       (rotation == 90 || rotation == 270)) {
+               DbgPrint("x %d, y %d w %d h %d, window_w %d window_h %d rotation %d",
+                               x, y, w, h, window_w, window_h, rotation);
+               return true;
+       }
+
+       return false;
+}
+
+static void __move_cb(void *data, Evas *e, Evas_Object *layout, void *event_info)
+{
+       struct widget_info *info = data;
+
+       if (__obj_is_visible(layout)) {
+               if (info->pid < 0) {
+                       info->restart = true;
+                       DbgPrint("restart! %s", info->widget_id);
+                       if (!info->disable_preview)
+                               elm_object_signal_emit(info->layout, "enable", "preview");
+
+                       if (!info->disable_loading) {
+                               elm_object_part_text_set(info->layout, "text", T_("IDS_ST_POP_LOADING_ING"));
+                               elm_object_signal_emit(info->layout, "enable", "text");
+                       }
+
+                       __restart_terminated_widget(info->widget_id);
+               }
+       }
+}
+
 static void _clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
 {
        struct widget_info *info = data;
@@ -1063,6 +1113,7 @@ static void __destroy_widget_info(gpointer data)
        if (info->layout) {
                evas_object_event_callback_del(info->layout, EVAS_CALLBACK_DEL, del_cb);
                evas_object_event_callback_del(info->layout, EVAS_CALLBACK_RESIZE, resize_cb);
+               evas_object_event_callback_del(info->layout, EVAS_CALLBACK_MOVE, __move_cb);
                elm_object_signal_callback_del(info->layout, "clicked", "reload", _clicked_cb);
        }
 
@@ -1116,6 +1167,7 @@ static struct widget_info *create_info(Evas_Object *parent, const char *widget_i
        evas_object_data_set(info->layout, WIDGET_INFO_TAG, info);
 
        evas_object_event_callback_add(info->layout, EVAS_CALLBACK_RESIZE, resize_cb, info);
+       evas_object_event_callback_add(info->layout, EVAS_CALLBACK_MOVE, __move_cb, info);
        evas_object_event_callback_add(info->layout, EVAS_CALLBACK_DEL, del_cb, info);
        elm_object_signal_callback_add(info->layout, "clicked", "reload", _clicked_cb, info);