Handle window pre visibility change event 98/125098/9
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 13 Apr 2017 22:30:31 +0000 (07:30 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 19 Jun 2017 07:28:53 +0000 (16:28 +0900)
When getting ECORE_WL_WINDOW_VISIBILITY_TYPE_PRE_UNOBSCURED event,
an application is changed to the resume state.
This patch is for backward compatibility.

+---------------+--------------------------------------------------+
| Tizen version | Window state                                     |
+---------------+--------------------------------------------------+
| 2.x           | Pause -> Resume(visibility change) -> Render     |
+---------------+--------------------------------------------------+
| 3.0 (before)  | Pause -> Render -> Resume(visibility change)     |
+---------------+--------------------------------------------------+
| 3.0 (after)   | Pause -> Resume(pre visibility change) -> Render |
+---------------+--------------------------------------------------+

Change-Id: Ife2da19a8675a8cce8beb1392720f785c40e569f
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/appcore_multiwindow_base.h
include/appcore_ui_base.h
src/multiwindow_base/appcore_multiwindow_base.c
src/multiwindow_base/appcore_multiwindow_base_private.h
src/multiwindow_base/appcore_multiwindow_base_window.c
src/ui_base/appcore_ui_base.c

index b5604ed..fcb90c9 100644 (file)
@@ -27,6 +27,7 @@ typedef struct _appcore_ui_base_window_ops {
        void (*hide)(int type, void *event, void *data);
        void (*lower)(int type, void *event, void *data);
        void (*visibility)(int type, void *event, void *data);
+       void (*pre_visibility)(int type, void *event, void *data);
 } appcore_ui_base_window_ops;
 
 typedef struct _appcore_multiwindow_base_ops {
@@ -64,6 +65,7 @@ void appcore_multiwindow_base_window_on_show(int type, void *event);
 void appcore_multiwindow_base_window_on_hide(int type, void *event);
 void appcore_multiwindow_base_window_on_lower(int type, void *event);
 void appcore_multiwindow_base_window_on_visibility(int type, void *event);
+void appcore_multiwindow_base_window_on_pre_visibility(int type, void *event);
 void appcore_multiwindow_base_window_bind(appcore_multiwindow_base_instance_h h, Evas_Object *win);
 
 appcore_multiwindow_base_class appcore_multiwindow_base_class_get_default(void);
index 3ce7867..9359564 100644 (file)
@@ -26,6 +26,7 @@ typedef struct _appcore_ui_base_window_ops {
        void (*hide)(int type, void *event, void *data);
        void (*lower)(int type, void *event, void *data);
        void (*visibility)(int type, void *event, void *data);
+       void (*pre_visibility)(int type, void *event, void *data);
 } appcore_ui_base_window_ops;
 
 typedef struct _appcore_ui_base_ops {
@@ -57,6 +58,7 @@ void appcore_ui_base_window_on_show(int type, void *event);
 void appcore_ui_base_window_on_hide(int type, void *event);
 void appcore_ui_base_window_on_lower(int type, void *event);
 void appcore_ui_base_window_on_visibility(int type, void *event);
+void appcore_ui_base_window_on_pre_visibility(int type, void *event);
 int appcore_ui_base_init(appcore_ui_base_ops ops, int argc, char **argv,
                void *data, unsigned int hint);
 void appcore_ui_base_fini(void);
index 66cfcf0..ca72c67 100644 (file)
@@ -71,6 +71,14 @@ static Eina_Bool __stub_lower_cb(void *data, int type, void *event)
        return ECORE_CALLBACK_RENEW;
 }
 
+static Eina_Bool __stub_pre_visibility_cb(void *data, int type, void *event)
+{
+       if (_appcore_mw_context.ops.window.pre_visibility)
+               _appcore_mw_context.ops.window.pre_visibility(type, event, _appcore_mw_context.data);
+
+       return ECORE_CALLBACK_RENEW;
+}
+
 EXPORT_API int appcore_multiwindow_base_init(appcore_multiwindow_base_ops ops, int argc, char **argv, void *data)
 {
        _appcore_mw_context.ops = ops;
@@ -130,6 +138,11 @@ EXPORT_API void appcore_multiwindow_base_fini(void)
                _appcore_mw_context.hlower = NULL;
        }
 
+       if (_appcore_mw_context.hpvchange) {
+               ecore_event_handler_del(_appcore_mw_context.hpvchange);
+               _appcore_mw_context.hpvchange = NULL;
+       }
+
        appcore_base_fini();
 }
 
@@ -174,6 +187,11 @@ static void __window_on_visibility(int type, void *event, void *data)
        appcore_multiwindow_base_window_on_visibility(type, event);
 }
 
+static void __window_on_pre_visibility(int type, void *event, void *data)
+{
+       appcore_multiwindow_base_window_on_pre_visibility(type, event);
+}
+
 static void __run(void *data)
 {
        elm_run();
@@ -221,6 +239,7 @@ EXPORT_API appcore_multiwindow_base_ops appcore_multiwindow_base_get_default_ops
        ops.window.hide = __window_on_hide;
        ops.window.lower = __window_on_lower;
        ops.window.visibility = __window_on_visibility;
+       ops.window.pre_visibility = __window_on_pre_visibility;
 
        return ops;
 }
@@ -241,6 +260,8 @@ EXPORT_API int appcore_multiwindow_base_on_create(void)
        _appcore_mw_context.hvchange = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE,
                        __stub_visibility_cb, NULL);
        _appcore_mw_context.hlower = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_LOWER, __stub_lower_cb, NULL);
+       _appcore_mw_context.hpvchange = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_PRE_VISIBILITY_CHANGE,
+                       __stub_pre_visibility_cb, NULL);
 
        return 0;
 }
index b28576d..15f2b2d 100644 (file)
@@ -65,6 +65,7 @@ typedef struct _appcore_multiwindow_base_context {
        Ecore_Event_Handler *hhide;
        Ecore_Event_Handler *hvchange;
        Ecore_Event_Handler *hlower;
+       Ecore_Event_Handler *hpvchange;
 } appcore_multiwindow_base_context;
 
 typedef struct _appcore_multiwindow_base_instance {
index 3aea29b..29dbf6d 100644 (file)
@@ -120,6 +120,18 @@ EXPORT_API void appcore_multiwindow_base_window_on_visibility(int type, void *ev
                appcore_multiwindow_base_instance_resume(cxt->inst);
 }
 
+EXPORT_API void appcore_multiwindow_base_window_on_pre_visibility(int type, void *event)
+{
+       Ecore_Wl_Event_Window_Pre_Visibility_Change *ev = event;
+       win_context *cxt = __find_win_context_by_wid(ev->win);
+
+       if (!cxt)
+               return;
+
+       if (ev->type == ECORE_WL_WINDOW_VISIBILITY_TYPE_PRE_UNOBSCURED)
+               appcore_multiwindow_base_instance_resume(cxt->inst);
+}
+
 EXPORT_API void appcore_multiwindow_base_window_bind(appcore_multiwindow_base_instance_h h, Evas_Object *win)
 {
        win_context *cxt;
index 0108d5f..d6521b3 100644 (file)
@@ -68,6 +68,7 @@ typedef struct _appcore_ui_base_context {
        Ecore_Event_Handler *hhide;
        Ecore_Event_Handler *hvchange;
        Ecore_Event_Handler *hlower;
+       Ecore_Event_Handler *hpvchange;
 } appcore_ui_base_context;
 
 
@@ -140,6 +141,14 @@ static Eina_Bool __stub_lower_cb(void *data, int type, void *event)
        return ECORE_CALLBACK_RENEW;
 }
 
+static Eina_Bool __stub_pre_visibility_cb(void *data, int type, void *event)
+{
+       if (__context.ops.window.pre_visibility)
+               __context.ops.window.pre_visibility(type, event, __context.data);
+
+       return ECORE_CALLBACK_RENEW;
+}
+
 static void __prepare_to_suspend(void)
 {
        int suspend = APPCORE_BASE_SUSPENDED_STATE_WILL_ENTER_SUSPEND;
@@ -502,6 +511,8 @@ EXPORT_API int appcore_ui_base_on_create(void)
        __context.hvchange = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE,
                                __stub_visibility_cb, NULL);
        __context.hlower = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_LOWER, __stub_lower_cb, NULL);
+       __context.hpvchange = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_PRE_VISIBILITY_CHANGE,
+                       __stub_pre_visibility_cb, NULL);
        __context.state = AS_CREATED;
        LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:create:done]", __context.appid);
 
@@ -680,6 +691,24 @@ EXPORT_API void appcore_ui_base_window_on_visibility(int type, void *event)
 
 }
 
+EXPORT_API void appcore_ui_base_window_on_pre_visibility(int type, void *event)
+{
+       Ecore_Wl_Event_Window_Pre_Visibility_Change *ev = event;
+       bool bvisibility;
+
+       if (ev && ev->type == ECORE_WL_WINDOW_VISIBILITY_TYPE_PRE_UNOBSCURED) {
+               __update_win((unsigned int)ev->win, 0, false);
+               bvisibility = __check_visible();
+
+               _DBG("bvisibility %d, b_active %d", bvisibility, b_active);
+               if (bvisibility && b_active == FALSE) {
+                       _DBG(" Go to Resume state\n");
+                       b_active = TRUE;
+                       __do_resume();
+               }
+       }
+}
+
 EXPORT_API int appcore_ui_base_init(appcore_ui_base_ops ops, int argc, char **argv,
                void *data, unsigned int hint)
 {
@@ -722,6 +751,8 @@ EXPORT_API void appcore_ui_base_fini(void)
                ecore_event_handler_del(__context.hvchange);
        if (__context.hlower)
                ecore_event_handler_del(__context.hlower);
+       if (__context.hpvchange)
+               ecore_event_handler_del(__context.hpvchange);
 
        __finish_wl();
 
@@ -813,6 +844,11 @@ static void __window_on_visibility(int type, void *event, void *data)
        appcore_ui_base_window_on_visibility(type, event);
 }
 
+static void __window_on_pre_visibility(int type, void *event, void *data)
+{
+       appcore_ui_base_window_on_pre_visibility(type, event);
+}
+
 EXPORT_API appcore_ui_base_ops appcore_ui_base_get_default_ops(void)
 {
        appcore_ui_base_ops ops;
@@ -834,6 +870,7 @@ EXPORT_API appcore_ui_base_ops appcore_ui_base_get_default_ops(void)
        ops.window.hide = __window_on_hide;
        ops.window.lower = __window_on_lower;
        ops.window.visibility = __window_on_visibility;
+       ops.window.pre_visibility = __window_on_pre_visibility;
 
        return ops;
 }