Update wm_client and applist
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Mon, 27 Aug 2018 10:15:30 +0000 (19:15 +0900)
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Mon, 27 Aug 2018 10:17:24 +0000 (19:17 +0900)
Change-Id: I76a58f431b894f2db1a8864f620c48311807befc
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
src/applist.cpp
src/applist.hpp
src/wm_client.cpp
src/wm_client.hpp

index 391a3ce..644e41e 100644 (file)
@@ -73,6 +73,14 @@ void AppList::addClient(const string &appid, unsigned layer, unsigned surface, c
     this->clientDump();
 }
 
+void AppList::addClient(const string &appid, unsigned layer, const string& layer_name, unsigned surface, const string &role)
+{
+    std::lock_guard<std::mutex> lock(this->mtx);
+    shared_ptr<WMClient> client = std::make_shared<WMClient>(appid, layer, layer_name, surface, role);
+    this->app2client[appid] = client;
+    this->clientDump();
+}
+
 /**
  * Remove WMClient from the list
  *
@@ -228,16 +236,15 @@ void AppList::removeFloatingSurface(unsigned surface)
     this->floating_surfaces.erase(fwd_itr, this->floating_surfaces.end());
 }
 
-WMError AppList::appendRole(const string &id, const string &role, unsigned surface)
+WMError AppList::appendRole(const string &id, const string &role)
 {
     WMError wm_err = WMError::NO_ENTRY;
-    HMI_ERROR("This function is disabled");
-    /* if (this->contains(id))
+    if (this->contains(id))
     {
         auto x = this->lookUpClient(id);
-        x->addSurface(role, surface);
+        x->appendRole(role);
         wm_err = WMError::SUCCESS;
-    } */
+    }
     return wm_err;
 }
 
index fef4d65..9e86b83 100644 (file)
@@ -50,14 +50,16 @@ class AppList
        If the WMClient should be more flexible, I think this param should be WMClient class
     */
     void addClient(const std::string &appid, unsigned layer,
-                    unsigned surface,const std::string &role);
+                    unsigned surface, const std::string &role);
+    void addClient(const std::string &appid, unsigned layer,
+        const std::string& layer_name, unsigned surface, const std::string &role);
     void removeClient(const std::string &appid);
     bool contains(const std::string &appid) const;
     int  countClient() const;
     std::shared_ptr<WMClient> lookUpClient(const std::string &appid);
     void removeSurface(unsigned surface);
     std::string getAppID(unsigned surface, const std::string &role, bool *found) const;
-    WMError appendRole(const std::string &appid, const std::string &role, unsigned surface);
+    WMError appendRole(const std::string &appid, const std::string &role);
 
     // Floating surface
     void addFloatingClient(const std::string &appid, unsigned layer, const std::string &role);
index 4aecbf4..7245549 100644 (file)
@@ -71,6 +71,23 @@ WMClient::WMClient(const string &appid, const string &role)
     }
 }
 
+WMClient::WMClient(const string &appid, unsigned layer,
+    const string& layer_name, unsigned surface, const string &role)
+    : id(appid), layer(layer), wm_layer_name(layer_name),
+      role2surface(0)
+{
+    role2surface[role] = surface;
+    for (auto x : kWMEvents)
+    {
+#if GTEST_ENABLED
+        string ev = x;
+#else
+        afb_event ev = afb_daemon_make_event(x.c_str());
+#endif
+        evname2afb_event[x] = ev;
+    }
+}
+
 string WMClient::appID() const
 {
     return this->id;
@@ -114,23 +131,13 @@ const string& WMClient::getWMLayerName()
 
 void WMClient::setRole(const string& role)
 {
+    this->role_list.clear();
     this->role_list.push_back(role);
 }
 
-/**
- * Set layerID the client belongs to
- *
- * This function set layerID the client belongs to.
- * But this function may not used because the layer should be fixed at constructor.
- * So this function will be used to change layer by some reasons.
- *
- * @param     unsigned[in] layerID
- * @return    None
- * @attention WMClient can't have multiple layer
- */
-void WMClient::registerLayer(unsigned layer)
+void WMClient::appendRole(const string& role)
 {
-    this->layer = layer;
+    this->role_list.push_back(role);
 }
 
 /**
index 0b5abe1..369f084 100644 (file)
@@ -42,6 +42,8 @@ class WMClient
     WMClient(const std::string &appid, unsigned layer,
             unsigned surface, const std::string &role);
     WMClient(const std::string &appid, const std::string &role);
+    WMClient(const std::string &appid, unsigned layer,
+        const std::string& layer_name, unsigned surface, const std::string &role);
     ~WMClient() = default;
 
     std::string appID() const;
@@ -53,7 +55,7 @@ class WMClient
     std::string role(unsigned surface) const;
     const std::vector<std::string> &roles() const;
     void setRole(const std::string& role);
-    void registerLayer(unsigned layer);
+    void appendRole(const std::string& role);
     bool addSurface(const std::string& role, unsigned surface);
     bool removeSurfaceIfExist(unsigned surface);
     bool removeRole(const std::string& role);