implement widget_context_foreach, add window cb 15/66315/2 accepted/tizen/common/20160419.143429 accepted/tizen/common/20160420.140428 accepted/tizen/ivi/20160419.152318 accepted/tizen/ivi/20160420.042444 accepted/tizen/mobile/20160419.151538 accepted/tizen/mobile/20160420.042349 accepted/tizen/tv/20160419.151833 accepted/tizen/tv/20160420.042407 accepted/tizen/wearable/20160419.152034 accepted/tizen/wearable/20160420.042432 submit/tizen/20160419.062501 submit/tizen/20160419.082844
authorDaehyeon Jung <darrenh.jung@samsung.com>
Mon, 18 Apr 2016 09:13:07 +0000 (18:13 +0900)
committerDaehyeon Jung <darrenh.jung@samsung.com>
Mon, 18 Apr 2016 09:15:06 +0000 (18:15 +0900)
Change-Id: I112c0e502ae7906e8cf4614377b32f7f4ac5f231
Signed-off-by: Daehyeon Jung <darrenh.jung@samsung.com>
src/widget_app.c

index 38cda3d..96212dc 100755 (executable)
@@ -293,6 +293,41 @@ static void __show_all()
        LOGD("resume");
 }
 
+static Eina_Bool __show_cb(void *data, int type, void *event)
+{
+       Ecore_Wl_Event_Window_Show *ev = event;
+       LOGD("show %d %d", (unsigned int)ev->win, (unsigned int)ev->data[0]);
+       return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool __hide_cb(void *data, int type, void *event)
+{
+       Ecore_Wl_Event_Window_Hide *ev = event;
+       LOGD("hide %d", (unsigned int)ev->win);
+       return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool __visibility_cb(void *data, int type, void *event)
+{
+       Ecore_Wl_Event_Window_Visibility_Change *ev = event;
+       LOGD("visiblity change: %d %d", (unsigned int)ev->win,  (unsigned int)ev->fully_obscured);
+       return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool __lower_cb(void *data, int type, void *event)
+{
+       LOGD("lower");
+       return ECORE_CALLBACK_RENEW;
+}
+
+static void __add_climsg()
+{
+       ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_SHOW, __show_cb, NULL);
+       ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_HIDE, __hide_cb, NULL);
+       ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE, __visibility_cb, NULL);
+       ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_LOWER, __lower_cb, NULL);
+}
+
 static int __aul_handler(aul_type type, bundle *b, void *data)
 {
        char *caller = NULL;
@@ -421,6 +456,8 @@ static int __before_loop(int argc, char **argv)
                                "Fail to call _set_i18n");
        }
 
+       __add_climsg();
+
        class_provider = app_ops->create(app_user_data);
        if (class_provider == NULL) {
                return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
@@ -528,6 +565,9 @@ EXPORT_API int widget_app_terminate_context(widget_context_h context)
 
 EXPORT_API int widget_app_foreach_context(widget_context_cb cb, void *data)
 {
+       GList *list;
+       widget_context_s *wc;
+
        if (!_is_widget_feature_enabled()) {
                _E("not supported");
                return WIDGET_ERROR_NOT_SUPPORTED;
@@ -536,6 +576,17 @@ EXPORT_API int widget_app_foreach_context(widget_context_cb cb, void *data)
        if (!cb)
                return WIDGET_ERROR_INVALID_PARAMETER;
 
+       list = g_list_first(contexts);
+
+       while (list) {
+               wc = (widget_context_s *)list->data;
+               if (wc) {
+                       if (!cb(wc, data))
+                               break;
+               }
+               list = list->next;
+       }
+
        return WIDGET_ERROR_NONE;
 }