X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwm_layer.cpp;h=773b5c23857abcb585e812cca68cf9ea11c79476;hb=0b011c00b0c8aa847a4d0aa460a335c5eae8f010;hp=613116523349594aecc10aef3f33865b6ce90853;hpb=2275abc95f65c364acefa36b6b2079caad305756;p=apps%2Fagl-service-windowmanager.git diff --git a/src/wm_layer.cpp b/src/wm_layer.cpp index 6131165..773b5c2 100644 --- a/src/wm_layer.cpp +++ b/src/wm_layer.cpp @@ -16,30 +16,57 @@ #include +#include "wm_client.hpp" #include "wm_layer.hpp" #include "json_helper.hpp" #include "util.hpp" using std::string; using std::vector; +using std::unordered_map; namespace wm { LayerState::LayerState() - : _ivi_layer_id_list(), - area2ivi_layer_id() + : render_order(), + area2appid() {} + +void LayerState::attachIdToArea(const string& area, const WMClient& client) +{ + this->area2appid[area] = client.appID(); + this->render_order.push_back(client.layerID()); +} + +const unordered_map LayerState::popCurrentState() +{ + unordered_map tmp = this->area2appid; + this->area2appid.clear(); + this->render_order.clear(); + return tmp; +} + +const unordered_map LayerState::getCurrentState() +{ + return this->area2appid; +} + +const vector LayerState::getIviIdList() +{ + return this->render_order; +} + LayerSetting::LayerSetting(const string& name, MANAGEMENT_TYPE type, unsigned begin, unsigned end) : name(name), type(type), role_list(), area_list(), id_list(), id_begin(begin), id_end(end) {} -void LayerSetting::appendRole(const string& role) +void LayerSetting::setRoleList(const string& role) { - this->role_list.push_back(role); + this->role_list = role; } void LayerSetting::appendArea(const string& area) @@ -50,20 +77,24 @@ void LayerSetting::appendArea(const string& area) unsigned LayerSetting::getNewLayerID(const string& role) { unsigned ret = 0; - auto found = std::find(role_list.cbegin(), role_list.cend(), role); - if(found == role_list.cend()) + auto re = std::regex(this->role_list); + if (std::regex_match(role, re)) + { + // generate new layer id; + ret = this->id_list.back() + 1; + HMI_DEBUG("role %s matches layer %d, new layerID %d", role.c_str(), this->name.c_str(), ret); + } + + if(ret == 0) { return ret; } - // generate new ivi layer id - ret = id_list.back() + 1; - HMI_INFO("generate ivi_layer_id : %d on the layer: %s", ret, this->name.c_str()); auto id_found = std::find(id_list.begin(), id_list.end(), ret); if( (ret > this->idEnd()) || (id_found != id_list.cend()) ) { HMI_NOTICE("id %d is not available then generate new id", ret); - ret = 0; + ret = 0; // reset for(unsigned i = this->idBegin(); i < this->idEnd(); i++) { auto ret_found = std::find(id_list.begin(), id_list.end(), i); @@ -108,13 +139,13 @@ WMLayer::WMLayer(json_object* j) : before_state(), state() { LayerSetting::MANAGEMENT_TYPE t; const char* layer_name = jh::getStringFromJson(j, "name"); - const char* role = jh::getStringFromJson(j, "role"); + const char* roles = jh::getStringFromJson(j, "role"); const char* type = jh::getStringFromJson(j, "type"); int begin = jh::getIntFromJson(j, "id_range_begin"); int end = jh::getIntFromJson(j, "id_range_end"); string name = layer_name; - if (layer_name || type || !begin < 0 || end < 0) + if (layer_name || type || begin < 0 || end < 0) { HMI_ERROR("Parse Error!!"); } @@ -123,9 +154,9 @@ WMLayer::WMLayer(json_object* j) : before_state(), state() HMI_ERROR("INVALID."); } string str_type = type; - t = (type == "tile") ? LayerSetting::TILE : LayerSetting::STACK; + t = (str_type == "tile") ? LayerSetting::TILE : LayerSetting::STACK; this->setting = std::make_unique(name, t, begin, end); - this->setting->appendRole(role); + this->setting->setRoleList(roles); } unsigned WMLayer::getNewLayerID(const std::string& role) @@ -135,6 +166,7 @@ unsigned WMLayer::getNewLayerID(const std::string& role) WMError WMLayer::setLayerState(const LayerState& l) { + this->before_state = l; return WMError::SUCCESS; } @@ -143,4 +175,14 @@ bool WMLayer::checkIDBelongTo(unsigned id) return (id > this->setting->idBegin() && id < this->setting->idEnd()); } +/* WMError WMLayer::commitChange() +{ + this->state = this->before_state; +} + +void WMLayer::undo() +{ + this->before_state = this->state; +} + */ } // namespace wm