Use pre visibility change event 93/182993/2
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 29 Jun 2018 11:27:43 +0000 (20:27 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 29 Jun 2018 11:50:16 +0000 (20:50 +0900)
Currently, we use iconify state change event to enable manual render.
Even if LCD state is off, watch-control gets iconify state change event.
This patch uses pre-visibility change event instead of iconify state
change event to handle LCD off scenario.

Change-Id: I5002214e1c56254986672c216aadf15313e098ee
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
watch-control/src/control.c

index 6deca36..9319d0a 100755 (executable)
@@ -73,10 +73,9 @@ static aul_app_com_connection_h __conn_dead_signal;
 static unsigned int __watch_rid;
 static bool __manual_render;
 static guint __manual_render_timer;
-static Ecore_Event_Handler *__iconify_change;
 static bool __is_bound = false;
-static bool __iconified = false;
 static int __viewer_visibility = AUL_SCREEN_STATUS_PAUSE;
+static Ecore_Event_Handler *__pre_visibility;
 
 static GList *__dead_cbs;
 struct dead_cb_s {
@@ -214,28 +213,35 @@ static void __manual_render_finish(void)
        }
 }
 
-static Eina_Bool __iconify_state_changed(void *data, int type, void *event)
+static Eina_Bool __window_on_pre_visibility(void *data, int type, void *event)
 {
-       Ecore_Wl2_Event_Window_Iconify_State_Change *ev =
-                       (Ecore_Wl2_Event_Window_Iconify_State_Change *)event;
-       Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(__win));
+       Ecore_Wl2_Event_Window_Pre_Visibility_Change *ev = event;
+       Ecore_Evas *ee;
+       Ecore_Wl2_Window *wl_win;
+       unsigned int win_id;
 
-       if(ev->win !=
-               ecore_wl2_window_id_get(ecore_evas_wayland2_window_get(ee)))
-               return ECORE_CALLBACK_PASS_ON;
+       if (!ev)
+               return ECORE_CALLBACK_RENEW;
 
-       LOGI("Iconify state changed, win(%d) is %s",
-                       ev->win,
-                       ev->iconified ? "iconified" : "uniconified");
+       ee = ecore_evas_ecore_evas_get(evas_object_evas_get(__win));
+       if (!ee)
+               return ECORE_CALLBACK_RENEW;
 
-       if (ev->iconified == EINA_FALSE && __iconified) {
+       wl_win = ecore_evas_wayland2_window_get(ee);
+       if (!wl_win)
+               return ECORE_CALLBACK_RENEW;
+
+       win_id = ecore_wl2_window_id_get(wl_win);
+       if (ev->win != win_id)
+               return ECORE_CALLBACK_RENEW;
+
+       if (ev && ev->type == ECORE_WL2_WINDOW_VISIBILITY_TYPE_PRE_UNOBSCURED) {
                __manual_render_start();
-               __iconified = false;
-       } else if (ev->iconified == EINA_TRUE) {
-               __iconified = true;
+               LOGD("[__WINDOW_PRE_VISIBILITY_CHANGE__] win_id(%u)",
+                               (unsigned int)ev->win);
        }
 
-       return ECORE_CALLBACK_PASS_ON;
+       return ECORE_CALLBACK_RENEW;
 }
 
 static int __watch_viewer_init(Evas_Object *win)
@@ -254,9 +260,13 @@ static int __watch_viewer_init(Evas_Object *win)
 
        __win_resized(NULL, NULL, win, NULL); /* init */
        evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, __win_resized, NULL);
-       __iconify_change = ecore_event_handler_add(
-                       ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE,
-                       __iconify_state_changed, NULL);
+
+       __pre_visibility = ecore_event_handler_add(
+                       ECORE_WL2_EVENT_WINDOW_PRE_VISIBILITY_CHANGE,
+                       __window_on_pre_visibility, NULL);
+       if (!__pre_visibility)
+               _E("Failed to add pre visibility change handler");
+
        __manual_render = false;
        __watch_viewer_initialized = 1;
 
@@ -265,6 +275,11 @@ static int __watch_viewer_init(Evas_Object *win)
 
 static void __watch_viewer_fini()
 {
+       if (__pre_visibility) {
+               ecore_event_handler_del(__pre_visibility);
+               __pre_visibility = NULL;
+       }
+
        if (__win) {
                evas_object_event_callback_del(__win, EVAS_CALLBACK_RESIZE, __win_resized);
                __win = NULL;
@@ -272,8 +287,6 @@ static void __watch_viewer_fini()
 
        screen_connector_toolkit_evas_stop_visibility_notify();
        screen_connector_toolkit_evas_fini(SCREEN_CONNECTOR_SCREEN_TYPE_WATCH);
-       if (__iconify_change)
-               ecore_event_handler_del(__iconify_change);
 }
 
 API int watch_manager_init(Evas_Object *win)