From ac17da7010c6bd90240a641d503991ca5d0cb41a Mon Sep 17 00:00:00 2001 From: "fukubayashi.akio" Date: Thu, 6 Jun 2019 17:55:08 +0900 Subject: Add chage remote app Signed-off-by: fukubayashi.akio --- src/wm_layer_control.cpp | 88 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 27 deletions(-) (limited to 'src/wm_layer_control.cpp') diff --git a/src/wm_layer_control.cpp b/src/wm_layer_control.cpp index 8086fd3..887fc58 100644 --- a/src/wm_layer_control.cpp +++ b/src/wm_layer_control.cpp @@ -26,11 +26,6 @@ #define LC_WESTON_SETTING_PATH "/etc/weston.json" #define LC_DEFAULT_AREA "fullscreen" #define BACK_GROUND_LAYER "BackGroundLayer" -#define REMOTE_LAYER "Remote" -#define REMOTE_LAYER_RSE1 "RemoteRSE1" -#define REMOTE_LAYER_RSE2 "RemoteRSE2" -#define REMOTE_LAYER_HUD "RemoteHUD" -#define REMOTE_LAYER_HUD_UL "RemoteHUDUpperLeft" #define AREA_NAME_RSE1 "rse1.normal.full" #define AREA_NAME_RSE2 "rse2.normal.full" #define AREA_NAME_HUD "hud.normal.full" @@ -398,6 +393,16 @@ WMError LayerControl::loadLayerSetting(const string &path) HMI_DEBUG("> json_tmp dump:%s", json_object_get_string(json_tmp)); this->wm_layers.emplace_back(std::make_shared(json_tmp, i)); + + int screen = jh::getIntFromJson(json_tmp, "screen"); + if (screen > 0) + { + std::string layerName = jh::getStringFromJson(json_tmp, "name"); + + HMI_DEBUG("Remote Layer Name:%s Screen: %d", layerName.c_str(), screen); + this->wm_remoteLayerName.push_back(layerName); + } + } json_object_put(json_obj); @@ -602,13 +607,13 @@ WMError LayerControl::visibilityChange(const WMAction& action) } else if (action.visible == TaskVisible::REMOTE_VISIBLE) { - this->moveRemote(action.client->layerID(), action.area); ret = this->makeVisible(action.client); + this->moveRemote(action.client->layerID(), action.area); } else if (action.visible == TaskVisible::REMOTE_INVISIBLE) { - this->moveLocal(action.client->layerID()); ret = this->makeInvisible(action.client); + this->moveLocal(action.client->layerID()); } else // TaskVisible::REQ_REMOTE_VISIBLE || TaskVisible::REQ_REMOTE_INVISIBLE { @@ -857,17 +862,16 @@ bool LayerControl::moveRemote(unsigned layer, const std::string& area) { bool ret = false; std::string remote_layer; + std::string ecu_name = area; + + if (area.find('.') != std::string::npos) + { + std::vector elements; + elements = parseString(area, '.'); + ecu_name = elements[0]; + } - if (area == AREA_NAME_RSE1) - remote_layer = REMOTE_LAYER_RSE1; - else if (area == AREA_NAME_RSE2) - remote_layer = REMOTE_LAYER_RSE2; - else if (area == AREA_NAME_HUD) - remote_layer = REMOTE_LAYER_HUD; - else if (area == AREA_NAME_HUD_UL) - remote_layer = REMOTE_LAYER_HUD_UL; - else - remote_layer = REMOTE_LAYER; + remote_layer = this->areaToRemoteLayer(ecu_name); auto remote = this->getWMLayer(remote_layer); @@ -880,12 +884,23 @@ bool LayerControl::moveRemote(unsigned layer, const std::string& area) remote->dump(); return ret; } + + shared_ptr wm_layer; + std::string wm_layer_name = this->hasRemoteLayer(layer); + + if(wm_layer_name == "") + { + wm_layer = this->getWMLayer(layer); + } + else + { + wm_layer = this->getWMLayer(wm_layer_name); + } + remote->addLayerToState(layer); - auto wm_layer = this->getWMLayer(layer); wm_layer->removeLayerFromState(layer); wm_layer->dump(); remote->dump(); - ret = true; } return ret; @@ -894,8 +909,11 @@ bool LayerControl::moveRemote(unsigned layer, const std::string& area) bool LayerControl::moveLocal(unsigned layer) { bool ret = false; + std::string remote_layer; - auto remote = this->getWMLayer(REMOTE_LAYER); + remote_layer = this->hasRemoteLayer(layer); + + auto remote = this->getWMLayer(remote_layer); if(remote != nullptr) { remote->removeLayerFromState(layer); @@ -909,17 +927,33 @@ bool LayerControl::moveLocal(unsigned layer) return ret; } -bool LayerControl::hasRemoteLayer(unsigned layer) +std::string LayerControl::hasRemoteLayer(unsigned layer) { - bool ret = false; - - auto remote = this->getWMLayer(REMOTE_LAYER); - if(remote != nullptr) + for (auto itr = wm_remoteLayerName.begin(); itr != wm_remoteLayerName.end(); ++itr) { - ret = remote->hasLayerFromState(layer); + auto remote = this->getWMLayer(*itr); + if(remote != nullptr) + { + if(remote->hasLayerFromState(layer)) + { + return *itr; + } + } } - return ret; + return ""; } +std::string LayerControl::areaToRemoteLayer(std::string area) +{ + for (auto itr = wm_remoteLayerName.begin(); itr != wm_remoteLayerName.end(); ++itr) + { + if (std::regex_search(*itr, std::regex(area, std::regex::icase))) + { + return *itr; + } + } + + return wm_remoteLayerName[0]; +} } // namespace wm -- cgit 1.2.3-korg