+void App::lm_layout_change(const char *drawing_name)
+{
+ auto const &surface_id = this->lookup_id(drawing_name);
+ 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;
+
+ // disable layers that are above our current layer
+ for (auto const &l : this->layers.mapping)
+ {
+ if (l.second.layer_id <= *layer_id)
+ {
+ continue;
+ }
+
+ bool flush = false;
+ if (l.second.state.main != -1)
+ {
+ this->deactivate(l.second.state.main);
+ l.second.state.main = -1;
+ flush = true;
+ }
+
+ if (l.second.state.sub != -1)
+ {
+ this->deactivate(l.second.state.sub);
+ l.second.state.sub = -1;
+ flush = true;
+ }
+
+ if (flush)
+ {
+ this->layout_commit();
+ }
+ }
+
+ auto layer = this->layers.get_layer(*layer_id);
+
+ if (state.main == -1)
+ {
+ this->try_layout(
+ state, LayoutState{*surface_id}, [&](LayoutState const &nl) {
+ HMI_DEBUG("wm", "Layout: %s", kNameLayoutNormal);
+ this->surface_set_layout(*surface_id);
+ state = nl;
+
+ // Commit for configuraton
+ this->layout_commit();
+
+ std::string str_area = std::string(kNameLayoutNormal) + "." + std::string(kNameAreaFull);
+ compositor::rect area_rect = this->area_info[*surface_id];
+ this->emit_syncdraw(drawing_name, str_area.c_str(),
+ area_rect.x, area_rect.y, area_rect.w, area_rect.h);
+ this->enqueue_flushdraw(state.main);
+ });
+ }
+ else
+ {
+ if (0 == strcmp(drawing_name, "HomeScreen"))
+ {
+ this->try_layout(
+ state, LayoutState{*surface_id}, [&](LayoutState const &nl) {
+ HMI_DEBUG("wm", "Layout: %s", kNameLayoutNormal);
+ std::string str_area = std::string(kNameLayoutNormal) + "." + std::string(kNameAreaFull);
+ compositor::rect area_rect = this->area_info[*surface_id];
+ this->emit_syncdraw(drawing_name, str_area.c_str(),
+ area_rect.x, area_rect.y, area_rect.w, area_rect.h);
+ this->enqueue_flushdraw(state.main);
+ });
+ }
+ else
+ {
+ bool can_split = this->can_split(state, *surface_id);
+
+ if (can_split)
+ {
+ this->try_layout(
+ state,
+ LayoutState{state.main, *surface_id},
+ [&](LayoutState const &nl) {
+ HMI_DEBUG("wm", "Layout: %s", kNameLayoutSplit);
+ std::string main =
+ std::move(*this->lookup_name(state.main));
+
+ this->surface_set_layout(state.main, surface_id);
+ if (state.sub != *surface_id)
+ {
+ if (state.sub != -1)
+ {
+ this->deactivate(state.sub);
+ }
+ }
+ state = nl;
+
+ // Commit for configuration and visibility(0)
+ this->layout_commit();
+
+ std::string str_area_main = std::string(kNameLayoutSplit) + "." + std::string(kNameAreaMain);
+ std::string str_area_sub = std::string(kNameLayoutSplit) + "." + std::string(kNameAreaSub);
+ compositor::rect area_rect_main = this->area_info[state.main];
+ compositor::rect area_rect_sub = this->area_info[*surface_id];
+ // >>> HACK
+ HMI_WARNING("wm", "HACK!!! mediaplayer and hvac is only supported for split");
+ std::string request_role = drawing_name;
+ //std::string request_app = transform(request_role.begin(), request_role.end(), request_role.begin(), tolower); //hvac or mediaplayer
+ std::string hack_appid = "navigation";
+ std::string hack_role = main;
+ std::string hack_area = str_area_main;
+ g_app_list.setAction(g_app_list.currentRequestNumber(), hack_appid, hack_role, hack_area, true);
+ //g_app_list.setEndDrawFinished(g_app_list.currentRequestNumber(), request_role, request_role);
+ //g_app_list.setEndDrawFinished(g_app_list.currentRequestNumber(), hack_appid, hack_role); // This process is illegal
+ // >>> HACK
+ this->emit_syncdraw(main.c_str(), str_area_main.c_str(),
+ area_rect_main.x, area_rect_main.y,
+ area_rect_main.w, area_rect_main.h);
+ this->emit_syncdraw(request_role.c_str(), str_area_sub.c_str(),
+ area_rect_sub.x, area_rect_sub.y,
+ area_rect_sub.w, area_rect_sub.h);
+ this->enqueue_flushdraw(state.main);
+ this->enqueue_flushdraw(state.sub);
+ });
+ }
+ else
+ {
+ this->try_layout(
+ state, LayoutState{*surface_id}, [&](LayoutState const &nl) {
+ HMI_DEBUG("wm", "Layout: %s", kNameLayoutNormal);
+
+ this->surface_set_layout(*surface_id);
+ if (state.main != *surface_id)
+ {
+ this->deactivate(state.main);
+ }
+ if (state.sub != -1)
+ {
+ if (state.sub != *surface_id)
+ {
+ this->deactivate(state.sub);
+ }
+ }
+ state = nl;
+
+ // Commit for configuraton and visibility(0)
+ this->layout_commit();
+
+ std::string str_area = std::string(kNameLayoutNormal) + "." + std::string(kNameAreaFull);
+ compositor::rect area_rect = this->area_info[*surface_id];
+ this->emit_syncdraw(drawing_name, str_area.c_str(),
+ area_rect.x, area_rect.y, area_rect.w, area_rect.h);
+ this->enqueue_flushdraw(state.main);
+ });
+ }
+ }
+ }
+}