+/* LCOV_EXCL_STOP */
+
+static void __destroy_all(int reason, int send_update)
+{
+ GList *contexts = _widget_app_get_contexts();
+ GList *iter = g_list_first(contexts);
+
+ __pause_all(send_update);
+ while (iter != NULL) {
+ widget_context_s *cxt = (widget_context_s *)iter->data;
+ iter = g_list_next(iter);
+ switch (cxt->state) {
+ case WC_PAUSED:
+ LOGD("destroy %d : %s", cxt->state, cxt->id);
+ __instance_destroy(cxt->provider, cxt->id, reason, send_update);
+ break;
+ }
+ }
+}
+
+
+static Eina_Bool __show_cb(void *data, int type, void *event)
+{
+ Ecore_Wl_Event_Window_Show *ev = event;
+ widget_context_s *cxt = __find_context_by_win(ev->win);
+
+ LOGD("show %d %d", (unsigned int)ev->win, (unsigned int)ev->data[0]);
+
+ if (cxt)
+ __instance_resume(cxt->provider, cxt->id, UPDATE_ALL);
+ else
+ LOGE("unknown window error: %d", ev->win); /* LCOV_EXCL_LINE */
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool __hide_cb(void *data, int type, void *event)
+{
+ Ecore_Wl_Event_Window_Hide *ev = event;
+ widget_context_s *cxt = __find_context_by_win(ev->win);
+
+
+ LOGD("hide %d", (unsigned int)ev->win);
+
+ if (cxt)
+ __instance_pause(cxt->provider, cxt->id, UPDATE_ALL);
+ else
+ LOGE("unknown window error: %d", ev->win); /* LCOV_EXCL_LINE */
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool __visibility_cb(void *data, int type, void *event)
+{
+ Ecore_Wl_Event_Window_Visibility_Change *ev = event;
+ widget_context_s *cxt = __find_context_by_win(ev->win);
+
+ LOGD("visiblity change: %d %d", (unsigned int)ev->win, (unsigned int)ev->fully_obscured);
+
+ if (!cxt) {
+ LOGE("unknown window error: %d", ev->win);
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (cxt->state == WC_PAUSED && ev->fully_obscured == 0) {
+ __instance_resume(cxt->provider, cxt->id, UPDATE_ALL);
+ } else if (cxt->state == WC_RUNNING && ev->fully_obscured == 1) {
+ __instance_pause(cxt->provider, cxt->id, UPDATE_ALL);
+ } else {
+ LOGD("cxt:%s state:%d obscured:%d", cxt->id, cxt->state, ev->fully_obscured);
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+/* LCOV_EXCL_START */
+static Eina_Bool __lower_cb(void *data, int type, void *event)
+{
+ LOGD("lower");
+ return ECORE_CALLBACK_RENEW;
+}
+/* LCOV_EXCL_STOP */
+
+static Eina_Bool __configure_cb(void *data, int type, void *event)
+{
+ Ecore_Wl_Event_Window_Configure *ev = event;
+ widget_context_s *cxt = __find_context_by_win(ev->win);
+
+ LOGD("configure: %d %d", ev->w, ev->h);
+
+ if (!cxt) {
+ LOGE("unknown window error: %d", ev->win); /* LCOV_EXCL_LINE */
+ return ECORE_CALLBACK_RENEW; /* LCOV_EXCL_LINE */
+ }
+
+ if (cxt->state == WC_PAUSED || cxt->state == WC_RUNNING)
+ __instance_resize(cxt->provider, cxt->id, ev->w, ev->h);
+ LOGD("cxt:%s resized to %dx%d", cxt->id, ev->w, ev->h);
+
+ 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);
+ ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_CONFIGURE, __configure_cb, NULL);
+}
+
+static void __get_content(bundle *b)
+{
+ char *instance_id = NULL;
+ widget_context_s *cxt = NULL;
+
+ bundle_get_str(b, AUL_K_WIDGET_INSTANCE_ID, &instance_id);
+ if (!instance_id)
+ return;
+
+ cxt = __find_context_by_id(instance_id);
+ if (!cxt) {
+ _E("can not find instance id:%s", instance_id);
+ return;
+ }
+
+ if (cxt->content) {
+ bundle_add_str(b, AUL_K_WIDGET_CONTENT_INFO, cxt->content);
+ _D("content info of %s found", cxt->id);
+ } else {
+ bundle_add_str(b, AUL_K_WIDGET_CONTENT_INFO, "");
+ _D("empty content info added");
+ }
+}