- this->emit_syncdraw(main.c_str());
- this->enqueue_flushdraw(state.main);
- });
- } else {
- return "Surface is not active";
- }
-
- return nullptr;
-}
-
-void App::enqueue_flushdraw(int surface_id) {
- this->check_flushdraw(surface_id);
- logdebug("Enqueuing EndDraw for surface_id %d", surface_id);
- this->pending_end_draw.push_back(surface_id);
-}
-
-void App::check_flushdraw(int surface_id) {
- auto i = std::find(std::begin(this->pending_end_draw),
- std::end(this->pending_end_draw), surface_id);
- if (i != std::end(this->pending_end_draw)) {
- auto n = this->lookup_name(surface_id);
- logerror("Application %s (%d) has pending EndDraw call(s)!",
- n ? n->c_str() : "unknown-name", surface_id);
- std::swap(this->pending_end_draw[std::distance(
- std::begin(this->pending_end_draw), i)],
- this->pending_end_draw.back());
- this->pending_end_draw.resize(this->pending_end_draw.size() - 1);
- }
-}
-
-char const *App::api_enddraw(char const *drawing_name) {
- for (unsigned i = 0, iend = this->pending_end_draw.size(); i < iend; i++) {
- auto n = this->lookup_name(this->pending_end_draw[i]);
- if (n && *n == drawing_name) {
- std::swap(this->pending_end_draw[i], this->pending_end_draw[iend - 1]);
- this->pending_end_draw.resize(iend - 1);
- // XXX: Please tell the compositor to thaw the surface...
- this->activate(this->pending_end_draw[i]);
- this->layout_commit();
- this->emit_flushdraw(drawing_name);
- return nullptr;
- }
- }
- return "No EndDraw pending for surface";
+ }
+ }
+
+ 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);
+ });
+ }
+ }
+ }