aboutsummaryrefslogtreecommitdiffstats
path: root/src/wm_layer.cpp
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-31 11:42:33 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-31 15:28:54 +0900
commit58561703d4053dfd454fe564b59215ce025c4a12 (patch)
tree56c7f14bb901a81300b3eaadf23de0017323218e /src/wm_layer.cpp
parentb73c8310f2ca06b356135ef3a1b17e5cb6e2ec5d (diff)
Update wm_layer
* Set Area when layoutChange * Implement hasRole Change-Id: I684f3bce700d0bb6f4d4a6ef1a3e5242856c192b Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src/wm_layer.cpp')
-rw-r--r--src/wm_layer.cpp55
1 files changed, 45 insertions, 10 deletions
diff --git a/src/wm_layer.cpp b/src/wm_layer.cpp
index f02a5b6..d74418a 100644
--- a/src/wm_layer.cpp
+++ b/src/wm_layer.cpp
@@ -41,7 +41,7 @@ void LayerState::attachIdToArea(const string& area, const WMClient& client)
this->render_order.push_back(client.layerID());
}
-const unordered_map<std::string, std::string> LayerState::popCurrentState()
+const unordered_map<string, string> LayerState::popCurrentState()
{
unordered_map<string, string> tmp = this->area2appid;
this->area2appid.clear();
@@ -49,7 +49,7 @@ const unordered_map<std::string, std::string> LayerState::popCurrentState()
return tmp;
}
-const unordered_map<std::string, std::string> LayerState::getCurrentState()
+const unordered_map<string, string> LayerState::getCurrentState()
{
return this->area2appid;
}
@@ -59,6 +59,27 @@ const vector<unsigned> LayerState::getIviIdList()
return this->render_order;
}
+void LayerState::addLayer(unsigned layer)
+{
+ this->render_order.push_back(layer);
+}
+
+void LayerState::removeLayer(unsigned layer)
+{
+ auto fwd_itr = std::remove_if(
+ this->render_order.begin(), this->render_order.end(),
+ [layer](unsigned elm) {
+ return elm == layer;
+ }
+ );
+ this->render_order.erase(fwd_itr, this->render_order.end());
+}
+
+void LayerState::setArea(const string& app, const string& area)
+{
+ this->area2appid[area] = app;
+}
+
WMLayer::WMLayer(json_object* j) : before_state(), state()
{
this->name = jh::getStringFromJson(j, "name");
@@ -84,15 +105,14 @@ WMLayer::WMLayer(json_object* j) : before_state(), state()
unsigned WMLayer::getNewLayerID(const string& role)
{
unsigned ret = 0;
- auto re = std::regex(this->role_list);
- if (std::regex_match(role, re))
+
+ // generate new layer id;
+ if(this->hasRole(role))
{
- // 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);
+ HMI_INFO("Generate new id: %d", ret);
}
-
- if(ret == 0)
+ else
{
return ret;
}
@@ -150,9 +170,24 @@ void WMLayer::removeLayerID(unsigned id)
this->id_list.erase(fwd_itr, this->id_list.end());
}
-bool WMLayer::checkIDBelongTo(unsigned id)
+bool WMLayer::hasLayerID(unsigned id)
{
- return (id > this->idBegin() && id < this->idEnd());
+ bool ret = (id > this->idBegin() && id < this->idEnd());
+ if(!ret)
+ return ret;
+ auto itr = std::find(this->id_list.begin(), this->id_list.end(), id);
+ return (itr != this->id_list.end()) ? true : false;
+}
+
+bool WMLayer::hasRole(const string& role)
+{
+ auto re = std::regex(this->role_list);
+ if (std::regex_match(role, re))
+ {
+ HMI_DEBUG("role %s matches layer %d", role.c_str(), this->name.c_str());
+ return true;
+ }
+ return false;
}
/* WMError WMLayer::commitChange()