addSurface to client
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Fri, 7 Sep 2018 05:09:19 +0000 (14:09 +0900)
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Fri, 7 Sep 2018 05:09:19 +0000 (14:09 +0900)
Change-Id: I2f09a94893699fc73bc82ac2caad5a9e282405b3
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
src/window_manager.cpp
src/window_manager.hpp
src/wm_client.cpp
src/wm_client.hpp

index a924ab5..7ee9dbd 100644 (file)
@@ -292,6 +292,8 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
     {
         // name does not exist yet, allocate surface id...
         auto id = int(this->id_alloc.generate_id(role));
+        this->tmp_surface2app[id] = s_appid;
+
         // this->layers.add_surface(id, *lid);
 
         // set the main_surface[_name] here and now
@@ -732,6 +734,17 @@ void WindowManager::send_event(char const *evname, char const *label, char const
 void WindowManager::surface_created(uint32_t surface_id)
 {
     HMI_DEBUG("current : %d", surface_id);
+    if(this->tmp_surface2app.count(surface_id) != 0)
+    {
+        string appid = this->tmp_surface2app[surface_id];
+        this->tmp_surface2app.erase(surface_id);
+        auto client = g_app_list.lookUpClient(appid);
+        bool ret = client->addSurface(surface_id);
+        if(!ret)
+        {
+            HMI_ERROR("Failed to add surface to client %s", client->appID().c_str());
+        }
+    }
     /* this->controller->get_surface_properties(surface_id, IVI_WM_PARAM_SIZE);
 
     auto layer_id = this->layers.get_layer_id(surface_id);
index f3b3c64..189d249 100644 (file)
@@ -266,6 +266,7 @@ class WindowManager
     rect_map area_info;
     // FOR CES DEMO
     std::vector<int> surface_bg;
+    std::unordered_map<unsigned, std::string> tmp_surface2app;
 
     static const char* kDefaultOldRoleDb;
 };
index 0f78f9f..500c60e 100644 (file)
@@ -17,6 +17,7 @@
 #include <json-c/json.h>
 #include "wm_client.hpp"
 #include "util.hpp"
+#include <ilm/ilm_control.h>
 
 #define INVALID_SURFACE_ID 0
 
@@ -155,7 +156,7 @@ void WMClient::appendRole(const string& role)
  * @param     unsigned[in] surface
  * @return    true
  */
-bool WMClient::addSurface(const string &role, unsigned surface)
+/* bool WMClient::addSurface(const string &role, unsigned surface)
 {
     HMI_DEBUG("Add role %s with surface %d", role.c_str(), surface);
     if (0 != this->role2surface.count(role))
@@ -164,6 +165,18 @@ bool WMClient::addSurface(const string &role, unsigned surface)
     }
     this->role2surface[role] = surface;
     return true;
+} */
+
+bool WMClient::addSurface(unsigned surface)
+{
+    this->surface = surface;
+    ilmErrorTypes err = ilm_layerAddSurface(this->layer, surface);
+
+    if(err == ILM_SUCCESS)
+    {
+        err = ilm_commitChanges();
+    }
+    return (err == ILM_SUCCESS) ? true : false;
 }
 
 bool WMClient::removeSurfaceIfExist(unsigned surface)
index 4bc9421..7c6c0b4 100644 (file)
@@ -57,7 +57,8 @@ class WMClient
     const std::vector<std::string> &roles() const;
     void setRole(const std::string& role);
     void appendRole(const std::string& role);
-    bool addSurface(const std::string& role, unsigned surface);
+    //bool addSurface(const std::string& role, unsigned surface);
+    bool addSurface(unsigned surface);
     bool removeSurfaceIfExist(unsigned surface);
     bool removeRole(const std::string& role);