From ce3b93a0db66002991973f83b41df609448418c4 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Mon, 17 Oct 2016 20:25:53 +0900 Subject: [PATCH] Fix resume, pause event Pause event called when instance is not visible Change-Id: I0950c564f59a1508c1caead58abef093b931af53 Signed-off-by: Hyunho Kang --- widget_toolkit/src/compositor.c | 48 +++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/widget_toolkit/src/compositor.c b/widget_toolkit/src/compositor.c index df6b424..29dee1e 100644 --- a/widget_toolkit/src/compositor.c +++ b/widget_toolkit/src/compositor.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -45,6 +46,7 @@ struct compositor_handler { void *data; Evas_Object *evas_obj; int freeze; + bool is_init; }; const char *__compositor_name = NULL; @@ -54,6 +56,35 @@ Ecore_Wl_Window *__window = NULL; unsigned int __window_id = 0; Ecore_Event_Handler *__visibility_listener = NULL; +static bool __obj_is_visible(Evas_Object *obj) +{ + int x, y, w, h; + evas_object_geometry_get(obj, &x, &y, &w, &h); + + if (x >= 0 && x < w) { + _D("x %d, y %d w %d h %d", x, y, w, h); + return true; + } + + return false; +} + +/* TODO : check y axis logic implementation */ +static void __obj_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + struct compositor_handler *handler = (struct compositor_handler *)data; + + if (!handler->is_init) { + handler->is_init = true; + return; + } + + if (__obj_is_visible(obj)) + _compositor_set_visibility(obj, VISIBILITY_TYPE_UNOBSCURED); + else + _compositor_set_visibility(obj, VISIBILITY_TYPE_FULLY_OBSCURED); +} + static void __obj_added_cb(void *data, Evas_Object *obj, void *event_info) { Evas_Object *added = (Evas_Object *)event_info; @@ -93,6 +124,8 @@ static void __obj_added_cb(void *data, Evas_Object *obj, void *event_info) if (handler->cb) handler->cb(handler->app_id, "added", added, handler->data); + + evas_object_event_callback_add(handler->evas_obj, EVAS_CALLBACK_MOVE, __obj_move_cb, handler); } static void __obj_deleted_cb(void *data, Evas_Object *obj, void *event_info) @@ -246,6 +279,7 @@ API int _compositor_set_handler(const char *app_id, _compositor_handler_cb cb, v handler->cb = cb; handler->data = data; handler->freeze = 0; + handler->is_init = false; g_hash_table_insert(__appid_tbl, handler->app_id, handler); @@ -277,7 +311,7 @@ API int _compositor_get_pid(Evas_Object *obj) API int _compositor_set_visibility(Evas_Object *obj, visibility_type type) { int obscured; - int ret; + Eina_Bool ret = EINA_TRUE; switch (type) { case VISIBILITY_TYPE_UNOBSCURED: @@ -294,7 +328,6 @@ API int _compositor_set_visibility(Evas_Object *obj, visibility_type type) } ret = pepper_efl_object_visibility_set(obj, obscured); - if (ret) /* EINA_TRUE on success */ return 0; @@ -339,17 +372,20 @@ static void __send_visibility(gpointer key, gpointer value, gpointer user_data) Evas_Object *evas_obj = (Evas_Object *)key; unsigned int event = GPOINTER_TO_INT(user_data); int ret; - Pepper_Efl_Visibility_Type type; + visibility_type type; if (handler->freeze) return; + if (!__obj_is_visible(evas_obj)) + return; + if (event) - type = PEPPER_EFL_VISIBILITY_TYPE_FULLY_OBSCURED; + type = VISIBILITY_TYPE_FULLY_OBSCURED; else - type = PEPPER_EFL_VISIBILITY_TYPE_UNOBSCURED; + type = VISIBILITY_TYPE_UNOBSCURED; - ret = pepper_efl_object_visibility_set(evas_obj, type); + ret = _compositor_set_visibility(evas_obj, type); if (!ret) { _E("failed to set pepper efl object visibility set %p to %d", evas_obj, type); -- 2.7.4