Update wm_layer* : Render order change
[apps/agl-service-windowmanager-2017.git] / src / wm_layer.cpp
index cd381c2..154d874 100644 (file)
@@ -71,6 +71,8 @@ void LayerState::removeLayer(unsigned layer)
     auto fwd_itr = std::remove_if(
         this->render_order.begin(), this->render_order.end(),
         [layer](unsigned elm) {
+            if(elm == layer)
+                HMI_DEBUG("remove layer %d", elm);
             return elm == layer;
         }
     );
@@ -82,6 +84,17 @@ void LayerState::setArea(const string& app, const string& area)
     this->area2appid[area] = app;
 }
 
+void LayerState::dump()
+{
+    std::string str;
+    for(const auto& ro : this->render_order)
+    {
+        str += std::to_string(ro);
+        str += ",";
+    }
+    DUMP("    render order : %s", str.c_str());
+}
+
 WMLayer::WMLayer(json_object* j, unsigned uuid) : tmp_state(), state(), uuid(uuid)
 {
     this->name = jh::getStringFromJson(j, "name");
@@ -107,6 +120,8 @@ WMLayer::WMLayer(json_object* j, unsigned uuid) : tmp_state(), state(), uuid(uui
 unsigned WMLayer::getNewLayerID(const string& role)
 {
     unsigned ret = 0;
+    if(this->name == BG_LAYER_NAME)
+        return ret;
 
     // generate new layer id;
     if(this->hasRole(role))
@@ -166,23 +181,31 @@ WMError WMLayer::setLayerState(const LayerState& l)
     return WMError::SUCCESS;
 }
 
-void WMLayer::addLayer(unsigned layer)
+void WMLayer::addLayerToState(unsigned layer)
 {
     this->tmp_state.addLayer(layer);
 }
 
+void WMLayer::removeLayerFromState(unsigned layer)
+{
+    this->tmp_state.removeLayer(layer);
+}
+
 void WMLayer::appendArea(const string& area)
 {
     this->area_list.push_back(area);
 }
 
-void WMLayer::removeLayerID(unsigned id)
+void WMLayer::terminateApp(unsigned id)
 {
     auto fwd_itr = std::remove_if(this->id_list.begin(), this->id_list.end(),
         [id](unsigned elm) {
             return elm == id;
         });
     this->id_list.erase(fwd_itr, this->id_list.end());
+    this->tmp_state.removeLayer(id);
+    this->state.removeLayer(id);
+    ilm_layerRemove(id);
 }
 
 bool WMLayer::hasLayerID(unsigned id)
@@ -196,9 +219,6 @@ bool WMLayer::hasLayerID(unsigned id)
 
 bool WMLayer::hasRole(const string& role)
 {
-    // TODO : use virtual to avoid compare
-    if(this->name == BG_LAYER_NAME)
-        return false;
     auto re = std::regex(this->role_list);
     if (std::regex_match(role, re))
     {
@@ -214,6 +234,16 @@ WMError WMLayer::commitChange()
     return WMError::SUCCESS;
 }
 
+void WMLayer::dump()
+{
+    DUMP("===== wm layer status =====");
+    DUMP("Layer :%s", this->name.c_str());
+    this->tmp_state.dump();
+    this->state.dump();
+    DUMP("===== wm layer status end =====");
+
+}
+
 /* void WMLayer::undo()
 {
     this->tmp_state = this->state;