Update wm_client
[apps/agl-service-windowmanager.git] / src / wm_layer_control.cpp
index 9c60286..9ac1ffc 100644 (file)
@@ -17,6 +17,8 @@
 #include <unistd.h>\r
 #include "wm_layer_control.hpp"\r
 #include "wm_layer.hpp"\r
+#include "wm_client.hpp"\r
+#include "request.hpp"\r
 #include "json_helper.hpp"\r
 \r
 #define LC_AREA_PATH "/etc/areas.db"\r
@@ -25,6 +27,7 @@
 \r
 using std::string;\r
 using std::vector;\r
+using std::shared_ptr;\r
 \r
 namespace wm {\r
 \r
@@ -319,6 +322,52 @@ WMError LayerControl::loadAreaDb(const std::string& path)
     return WMError::SUCCESS;\r
 }\r
 \r
+WMError LayerControl::layoutChange(const WMAction& action)\r
+{\r
+    WMError ret = WMError::FAIL;\r
+    if (action.visible == TaskVisible::INVISIBLE)\r
+    {\r
+        // Visibility is not change -> no redraw is required\r
+        return WMError::SUCCESS;\r
+    }\r
+    if(action.client == nullptr)\r
+    {\r
+        HMI_SEQ_ERROR(action.req_num, "client may vanish");\r
+        return WMError::NOT_REGISTERED;\r
+    }\r
+    unsigned layer = action.client->layerID();\r
+\r
+    // Layout Manager\r
+    // WMError ret = this->setLayerSize(layer, action.area);\r
+    auto rect = this->getAreaSize(action.area);\r
+    ilmErrorTypes err = ilm_layerSetDestinationRectangle(layer, rect.x, rect.y, rect.w, rect.h);\r
+    if(err == ILM_SUCCESS)\r
+    {\r
+        ret = WMError::SUCCESS;\r
+    }\r
+    return ret;\r
+}\r
+\r
+WMError LayerControl::visibilityChange(const WMAction& action)\r
+{\r
+    WMError ret = WMError::FAIL;\r
+    if(action.client == nullptr)\r
+    {\r
+        HMI_SEQ_ERROR(action.req_num, "client may vanish");\r
+        return WMError::NOT_REGISTERED;\r
+    }\r
+\r
+    if (action.visible != TaskVisible::INVISIBLE)\r
+    {\r
+        ret = this->makeVisible(action.client);\r
+    }\r
+    else\r
+    {\r
+        ret = this->makeInvisible(action.client);\r
+    }\r
+    return ret;\r
+}\r
+\r
 void LayerControl::dispatchCreateEvent(ilmObjectType object, unsigned id, bool created)\r
 {\r
     this->cb.test(id);\r
@@ -477,4 +526,61 @@ void LayerControl::dispatchPropertyChangeEvent(unsigned id,
     }\r
 }\r
 \r
+WMError LayerControl::makeVisible(const shared_ptr<WMClient> client)\r
+{\r
+    WMError ret = WMError::FAIL;\r
+    // Don't check here the client is not nullptr\r
+    unsigned layer = client->layerID();\r
+    bool contains;// = this->checkBackGround(action.client->role());\r
+    if(contains)\r
+    {\r
+        shared_ptr<WMLayer> l;\r
+        // Move background from back ground layer\r
+        for(const auto& wm_layer : this->wm_layers)\r
+        {\r
+            if(wm_layer->layerName() == "BackGroundLayer")\r
+            {\r
+                //wm_layer.removeLayer(layer);\r
+            }\r
+            else\r
+            {\r
+                if(wm_layer->checkIDBelongTo(layer))\r
+                {\r
+                    l = wm_layer;\r
+                }\r
+            }\r
+        }\r
+        if(l != nullptr)\r
+        {\r
+            // make invisible first\r
+            ilm_layerSetVisibility(layer, 0);\r
+            ilm_commitChanges();\r
+            //l->addLayer(layer);\r
+        }\r
+    }\r
+    for(const auto& wm_layer : this->wm_layers)\r
+    {\r
+        // make visible\r
+        //l->makeVisible(layer);\r
+    }\r
+\r
+    return ret;\r
+}\r
+\r
+WMError LayerControl::makeInvisible(const shared_ptr<WMClient> client)\r
+{\r
+    WMError ret = WMError::FAIL;\r
+    // Don't check here the client is not nullptr\r
+    unsigned layer = client->layerID();\r
+    bool contains;// = this->checkBackGround(client->role());\r
+    if(contains)\r
+    {\r
+        // Pop from background\r
+    }\r
+    else\r
+    {\r
+\r
+    }\r
+    return ret;\r
+}\r
 } // namespace wm
\ No newline at end of file