Handle window pre visibility change event
[platform/core/appfw/app-core.git] / src / ui_base / appcore_ui_base.c
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;
 }