Improve window manager
[apps/agl-service-windowmanager-2017.git] / src / wm_layer_control.cpp
index 80dc0c9..75c35da 100644 (file)
@@ -22,7 +22,7 @@
 #include "json_helper.hpp"
 
 #define LC_AREA_PATH "/etc/areas.json"
-#define LC_LAYER_SETTING_PATH "/etc/layers_setting.json"
+#define LC_LAYER_SETTING_PATH "/etc/layers.json"
 #define LC_DEFAULT_AREA "fullscreen"
 #define BACK_GROUND_LAYER "BackGroundLayer"
 
@@ -171,8 +171,8 @@ unsigned LayerControl::getNewLayerID(const string& role, string* layer_name)
         if(ret != 0)
         {
             *layer_name = l->layerName();
-            unsigned uid = l->getUuid();
-            this->lid2wmlid[ret] = uid;
+            unsigned wmlid = l->getWMLayerID();
+            this->lid2wmlid[ret] = wmlid;
             break;
         }
     }
@@ -181,8 +181,8 @@ unsigned LayerControl::getNewLayerID(const string& role, string* layer_name)
 
 shared_ptr<WMLayer> LayerControl::getWMLayer(unsigned layer)
 {
-    unsigned uuid = this->lid2wmlid[layer];
-    return this->wm_layers[uuid];
+    unsigned wm_lid = this->lid2wmlid[layer];
+    return this->wm_layers[wm_lid];
 }
 
 std::shared_ptr<WMLayer> LayerControl::getWMLayer(std::string layer_name)
@@ -574,11 +574,11 @@ WMError LayerControl::layoutChange(const WMAction& action)
         // Store the state who is assigned to the area
         if(wm_layer->hasLayerID(layer))
         {
-            wm_layer->setAreaToState(action.client->appID(), action.area);
+            wm_layer->attachAppToArea(action.client->appID(), action.area);
             /* TODO: manipulate state directly
-               LayerState ls = wm_layer->getLayerState();
-               ls.setArea(action.client->appID(), action.area);
-               wm_layer->dump(); */
+            LayerState ls = wm_layer->getLayerState();
+            ls.seattachAppToAreatArea(action.client->appID(), action.area);
+            wm_layer->dump(); */
         }
     }
 
@@ -619,11 +619,14 @@ WMError LayerControl::visibilityChange(const WMAction& action)
     return ret;
 }
 
-void LayerControl::terminateApp(const shared_ptr<WMClient> client)
+void LayerControl::appTerminated(const shared_ptr<WMClient> client)
 {
     for(auto& l : this->wm_layers)
     {
-        l->terminateApp(client->layerID());
+        if(l->hasLayerID(client->layerID()))
+        {
+            l->appTerminated(client->layerID());
+        }
     }
 }
 
@@ -724,43 +727,21 @@ void LayerControl::dispatchLayerPropChangeEvent(unsigned id,
 WMError LayerControl::makeVisible(const shared_ptr<WMClient> client)
 {
     WMError ret = WMError::SUCCESS;
-    // Don't check here the client is not nullptr
+    // Don't check here wheher client is nullptr or not
     unsigned layer = client->layerID();
 
     this->moveForeGround(client);
 
     ilm_layerSetVisibility(layer, ILM_TRUE);
 
-    /* for(auto& wm_layer : this->wm_layers)
-    {
-        if(wm_layer->hasLayerID(layer))
-        {
-            LayerState ls = wm_layer->getLayerState();
-            ls.addLayer(layer);;
-        }
-    } */
-
-    // Move foreground from back ground layer
-    /* for(auto& wm_layer : this->wm_layers)
-    {
-        if(wm_layer->layerName() == "BackGroundLayer")
-        {
-            if(wm_layer->hasRole(client->role()))
-            {
-                LayerState ls = wm_layer->getLayerState();
-                ls.removeLayer(layer);
-            }
-            break;
-        }
-    } */
-
     return ret;
 }
 
 WMError LayerControl::makeInvisible(const shared_ptr<WMClient> client)
 {
     WMError ret = WMError::SUCCESS;
-    unsigned layer = client->layerID(); // Don't check here the client is not nullptr
+    // Don't check here the client is not nullptr
+    unsigned layer = client->layerID();
 
     bool mv_ok = this->moveBackGround(client);
 
@@ -770,19 +751,6 @@ WMError LayerControl::makeInvisible(const shared_ptr<WMClient> client)
         ilm_layerSetVisibility(layer, ILM_FALSE);
     }
 
-    //ilm_layerSetDestinationRectangle(layer, 0, 0, 0, 0);
-
-    /* for(auto& wm_layer : this->wm_layers)
-    {
-        if(wm_layer->hasLayerID(layer))
-        {
-            LayerState ls = wm_layer->getLayerState();
-            ls.removeLayer(layer);;
-        }
-    } */
-
-
-
     return ret;
 }
 
@@ -908,4 +876,4 @@ bool LayerControl::moveForeGround(const shared_ptr<WMClient> client)
     return ret;
 }
 
-} // namespace wm
+} // namespace wm
\ No newline at end of file