+#if defined(X11)
+static struct ui_wm_rotate wm_rotate;
+#endif
+static Eina_Bool __visibility_cb(void *data, int type, void *event);
+static GSList *g_winnode_list;
+
+static struct wl_display *dsp;
+static struct wl_registry *reg;
+static struct tizen_policy *tz_policy;
+static bool bg_state = false;
+
+static void __wl_listener_cb(void *data, struct wl_registry *reg,
+ uint32_t id, const char *interface, uint32_t ver)
+{
+ if (interface && !strcmp(interface, "tizen_policy")) {
+ if (!tz_policy)
+ tz_policy = wl_registry_bind(reg, id,
+ &tizen_policy_interface, 1);
+ }
+}
+
+static void __wl_listener_remove_cb(void *data, struct wl_registry *reg,
+ unsigned int id)
+{
+ /* do nothing */
+}
+
+static const struct wl_registry_listener reg_listener = {
+ __wl_listener_cb,
+ __wl_listener_remove_cb
+};
+
+static int __init_wl(void)
+{
+ _DBG("initialize wayland");
+ dsp = wl_display_connect(NULL);
+ if (dsp == NULL) {
+ _ERR("Failed to connect wl display");
+ return -1;
+ }
+
+ reg = wl_display_get_registry(dsp);
+ if (reg == NULL) {
+ _ERR("Failed to get registry");
+ wl_display_disconnect(dsp);
+ return -1;
+ }
+
+ wl_registry_add_listener(reg, ®_listener, NULL);
+ wl_display_roundtrip(dsp);
+
+ if (!tz_policy) {
+ _ERR("Failed to get tizen policy interface");
+ wl_registry_destroy(reg);
+ wl_display_disconnect(dsp);
+ return -1;
+ }
+
+ return 0;
+}
+
+static void __finish_wl(void)
+{
+ if (tz_policy) {
+ tizen_policy_destroy(tz_policy);
+ tz_policy = NULL;
+ }
+
+ if (reg) {
+ wl_registry_destroy(reg);
+ reg = NULL;
+ }
+
+ if (dsp) {
+ wl_display_disconnect(dsp);
+ dsp = NULL;
+ }
+}
+
+static void __set_bg_state(void)
+{
+ if (__init_wl() < 0)
+ return;
+
+ tizen_policy_set_background_state(tz_policy, getpid());
+ wl_display_roundtrip(dsp);
+ bg_state = true;
+ _DBG("bg state: %d", bg_state);
+}
+
+static void __unset_bg_state(void)
+{
+ if (!tz_policy)
+ return;
+
+ tizen_policy_unset_background_state(tz_policy, getpid());
+ wl_display_roundtrip(dsp);
+ bg_state = false;
+ _DBG("bg state: %d", bg_state);
+ __finish_wl();
+}
+
+#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
+static void __appcore_efl_prepare_to_suspend(void *data)
+{
+ struct ui_priv *ui = (struct ui_priv *)data;
+ struct sys_op *op = NULL;
+ int suspend = APPCORE_SUSPENDED_STATE_WILL_ENTER_SUSPEND;
+
+ if (ui->app_core && !ui->app_core->allowed_bg && !ui->app_core->suspended_state) {
+ op = &ui->app_core->sops[SE_SUSPENDED_STATE];
+ if (op && op->func)
+ op->func((void *)&suspend, op->data); /* calls c-api handler */
+
+ ui->app_core->suspended_state = true;
+ }
+ _DBG("[__SUSPEND__]");
+}
+
+static void __appcore_efl_exit_from_suspend(void *data)