Add setRenderOrder into WMClient
[apps/agl-service-windowmanager-2017.git] / src / wm_client.cpp
index 691c3cb..84f9842 100644 (file)
@@ -142,6 +142,52 @@ bool WMClient::removeSurfaceIfExist(unsigned surface)
     return ret;
 }
 
+WMError WMClient::setRenderOrder(const vector<string> &order)
+{
+    WMError ret = WMError::SUCCESS;
+    this->surface_render_order.clear();
+    for(const auto& x : order)
+    {
+        unsigned s; // surface
+        if(x == this->role())
+        {
+            s = this->surfaceID();
+        }
+        else if(this->service2surfaces.count(x) != 0)
+        {
+            s = this->service2surfaces[x];
+        }
+        else
+        {
+            ret = WMError::NOT_REGISTERED;
+            break;
+        }
+        this->surface_render_order.push_back(s);
+    }
+    if(ret == WMError::SUCCESS)
+    {
+        int count = 0;
+        t_ilm_layer* id_array = new t_ilm_surface[this->surface_render_order.size()];
+        if(id_array == nullptr)
+        {
+            HMI_WARNING("short memory");
+            ret = WMError::FAIL;
+        }
+        else
+        {
+            for(const auto& i : this->surface_render_order)
+            {
+                id_array[count] = i;
+                ++count;
+            }
+            ilm_layerSetRenderOrder(this->layerID(),
+                id_array, this->surface_render_order.size());
+            delete id_array;
+        }
+    }
+    return ret;
+}
+
 #if GTEST_ENABLED
 bool WMClient::subscribe(afb_req req, const string &evname)
 {