+WMError WindowManager::setInvisibleTask(const std::string &role, bool split)
+{
+ unsigned req_num = g_app_list.currentRequestNumber();
+ HMI_SEQ_DEBUG(req_num, "set current visible app to invisible task");
+ // This task is copied from original actiavete surface
+ const char *drawing_name = this->rolenew2old[role].c_str();
+ auto const &surface_id = this->lookup_id(role.c_str());
+ auto layer_id = this->layers.get_layer_id(*surface_id);
+ auto o_state = *this->layers.get_layout_state(*surface_id);
+ struct LayoutState &state = *o_state;
+ std::string add_name, add_role;
+ std::string add_area = "";
+ int surface;
+ TaskVisible task_visible = TaskVisible::INVISIBLE;
+ bool end_draw_finished = true;
+ bool found = false;
+
+ for (auto const &l : this->layers.mapping)
+ {
+ if (l.second.layer_id <= *layer_id)
+ {
+ continue;
+ }
+ HMI_DEBUG("wm", "debug: main %d , sub : %d", l.second.state.main, l.second.state.sub);
+ if (l.second.state.main != -1)
+ {
+ //this->deactivate(l.second.state.main);
+ surface = l.second.state.main;
+ add_role = *this->id_alloc.lookup(surface);
+ add_name = g_app_list.getAppID(surface, add_role, &found);
+ if(!found){
+ return WMError::NOT_REGISTERED;
+ }
+ HMI_SEQ_INFO(req_num, "Invisible %s", add_name.c_str());
+ WMAction act{add_name, add_role, add_area, task_visible, end_draw_finished};
+ g_app_list.setAction(req_num, act);
+ l.second.state.main = -1;
+ }
+
+ if (l.second.state.sub != -1)
+ {
+ //this->deactivate(l.second.state.sub);
+ surface = l.second.state.sub;
+ add_role = *this->id_alloc.lookup(surface);
+ add_name = g_app_list.getAppID(surface, add_role, &found);
+ if (!found)
+ {
+ return WMError::NOT_REGISTERED;
+ }
+ HMI_SEQ_INFO(req_num, "Invisible %s", add_name.c_str());
+ WMAction act{add_name, add_role, add_area, task_visible, end_draw_finished};
+ g_app_list.setAction(req_num, act);
+ l.second.state.sub = -1;
+ }
+ }
+
+ // change current state here, but this is hack
+ auto layer = this->layers.get_layer(*layer_id);
+
+ if (state.main == -1)
+ {
+ HMI_DEBUG("wm", "Layout: %s", kNameLayoutNormal);
+ }
+ else
+ {
+ if (0 != strcmp(drawing_name, "HomeScreen"))
+ {
+ if (split)
+ {
+ if (state.sub != *surface_id)
+ {
+ if (state.sub != -1)
+ {
+ //this->deactivate(state.sub);
+ WMAction deact_sub;
+ deact_sub.role =
+ std::move(*this->id_alloc.lookup(state.sub));
+ deact_sub.area = add_area;
+ deact_sub.appid = g_app_list.getAppID(state.sub, deact_sub.role, &found);
+ if (!found)
+ {
+ HMI_SEQ_ERROR(req_num, "App doesn't exist for role : %s",
+ deact_sub.role.c_str());
+ return WMError::NOT_REGISTERED;
+ }
+ deact_sub.visible = task_visible;
+ deact_sub.end_draw_finished = end_draw_finished;
+ HMI_SEQ_DEBUG(req_num, "Set invisible task for %s", deact_sub.appid.c_str());
+ g_app_list.setAction(req_num, deact_sub);
+ }
+ }
+ //state = LayoutState{state.main, *surface_id};
+ }
+ else
+ {
+ HMI_DEBUG("wm", "Layout: %s", kNameLayoutNormal);
+
+ //this->surface_set_layout(*surface_id);
+ if (state.main != *surface_id)
+ {
+ // this->deactivate(state.main);
+ WMAction deact_main;
+ deact_main.role = std::move(*this->id_alloc.lookup(state.main));
+ ;
+ deact_main.area = add_area;
+ deact_main.appid = g_app_list.getAppID(state.main, deact_main.role, &found);
+ if (!found)
+ {
+ HMI_SEQ_DEBUG(req_num, "sub surface ddoesn't exist");
+ return WMError::NOT_REGISTERED;
+ }
+ deact_main.visible = task_visible;
+ deact_main.end_draw_finished = end_draw_finished;
+ HMI_SEQ_DEBUG(req_num, "sub surface doesn't exist");
+ g_app_list.setAction(req_num, deact_main);
+ }
+ if (state.sub != -1)
+ {
+ if (state.sub != *surface_id)
+ {
+ //this->deactivate(state.sub);
+ WMAction deact_sub;
+ deact_sub.role = std::move(*this->id_alloc.lookup(state.sub));
+ ;
+ deact_sub.area = add_area;
+ deact_sub.appid = g_app_list.getAppID(state.sub, deact_sub.role, &found);
+ if (!found)
+ {
+ HMI_SEQ_DEBUG(req_num, "sub surface ddoesn't exist");
+ return WMError::NOT_REGISTERED;
+ }
+ deact_sub.visible = task_visible;
+ deact_sub.end_draw_finished = end_draw_finished;
+ HMI_SEQ_DEBUG(req_num, "sub surface doesn't exist");
+ g_app_list.setAction(req_num, deact_sub);
+ }
+ }
+ //state = LayoutState{*surface_id};
+ }
+ }
+ }
+ return WMError::SUCCESS;
+}
+