Remove wm_layer_name in wm_client
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Fri, 7 Sep 2018 02:27:06 +0000 (11:27 +0900)
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Fri, 7 Sep 2018 02:27:06 +0000 (11:27 +0900)
Change-Id: I6b146ca41f9be311d0d21163e5fe23aeabbfe3fc
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
src/applist.cpp
src/applist.hpp
src/window_manager.cpp
src/wm_client.cpp
src/wm_client.hpp
src/wm_layer.hpp

index 93c90ac..e27bd03 100644 (file)
@@ -73,10 +73,10 @@ 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)
+void AppList::addClient(const string &appid, unsigned layer, 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);
+    shared_ptr<WMClient> client = std::make_shared<WMClient>(appid, layer, role);
     this->app2client[appid] = client;
     this->clientDump();
 }
index 1bc27c6..98ce1b8 100644 (file)
@@ -51,8 +51,7 @@ class AppList
     */
     void addClient(const std::string &appid, unsigned layer,
                     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 addClient(const std::string &appid, unsigned layer, const std::string &role);
     void removeClient(const std::string &appid);
     bool contains(const std::string &appid) const;
     int  countClient() const;
index fc333d4..a924ab5 100644 (file)
@@ -260,25 +260,31 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
     //       so convert role old to new
     const char *role = this->convertRoleOldToNew(drawing_name);
     string l_name;
+    string s_appid = appid;
+    string s_role = drawing_name;
 
-    // auto lid = this->layers.get_layer_id(string(role));
-    unsigned l_id = this->lc->getNewLayerID(role, &l_name);
-    if (l_id == 0)
+    if(!g_app_list.contains(s_appid))
     {
-        /**
-       * register drawing_name as fallback and make it displayed.
-       */
-        // lid = this->layers.get_layer_id(string("fallback"));
-        l_id = this->lc->getNewLayerID("fallback", &l_name);
-        HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role);
+        // auto lid = this->layers.get_layer_id(string(role));
+        unsigned l_id = this->lc->getNewLayerID(s_role, &l_name);
         if (l_id == 0)
         {
-            return Err<int>("Designated role does not match any role, fallback is disabled");
+            /**
+         * register drawing_name as fallback and make it displayed.
+         */
+            // lid = this->layers.get_layer_id(string("fallback"));
+            l_id = this->lc->getNewLayerID("fallback", &l_name);
+            HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role);
+            if (l_id == 0)
+            {
+                return Err<int>("Designated role does not match any role, fallback is disabled");
+            }
         }
+        this->lc->createNewLayer(l_id);
+        // add client into the db
+        g_app_list.addClient(s_appid, l_id, s_role);
     }
 
-    this->lc->createNewLayer(l_id);
-
     // generate surface ID for ivi-shell application
 
     auto rname = this->id_alloc.lookup(string(role));
@@ -296,9 +302,7 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
         //     HMI_DEBUG("Set main_surface id to %u", id);
         // }
 
-        // add client into the db
-        string appid_str(appid);
-        g_app_list.addClient(appid_str, l_id, l_name, id, string(role));
+
 
         /* if(g_app_list.contains(appid_str))
         {
@@ -366,7 +370,7 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
 
     // add client into the db
     string appid_str(appid);
-    g_app_list.addClient(appid_str, lid, l_name, sid, string(role));
+    g_app_list.addClient(appid_str, lid, string(role));
 
     // Set role map of (new, old)
     this->rolenew2old[role] = string(drawing_name);
@@ -434,7 +438,7 @@ bool WindowManager::api_set_role(char const *appid, char const *drawing_name, un
     else{
         HMI_INFO("Create new client: %s, surface: %d into layer: %d with role: %s",
                  id.c_str(), surface, lid, role.c_str());
-        g_app_list.addClient(id, lid, l_name, surface, role);
+        g_app_list.addClient(id, lid, role);
     }
 
     // register pair drawing_name and ivi_id
index 3bc2d31..0f78f9f 100644 (file)
@@ -71,12 +71,14 @@ 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)
+WMClient::WMClient(const string &appid, unsigned layer, const string &role)
+    : id(appid),
+      layer(layer),
+      main_role(role),
+      role2surface(0),
+      evname2afb_event(0)
 {
-    role2surface[role] = surface;
+    role2surface[role] = INVALID_SURFACE_ID;
     for (auto x : kWMEvents)
     {
 #if GTEST_ENABLED
@@ -129,11 +131,6 @@ unsigned WMClient::surfaceID() const
     return this->surface;
 }
 
-const string& WMClient::getWMLayerName()
-{
-    return this->wm_layer_name;
-}
-
 void WMClient::setRole(const string& role)
 {
     this->role_list.clear();
index c78d6f9..4bc9421 100644 (file)
@@ -42,6 +42,7 @@ 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 &role);
     WMClient(const std::string &appid, unsigned layer,
         const std::string& layer_name, unsigned surface, const std::string &role);
     ~WMClient() = default;
@@ -49,7 +50,6 @@ class WMClient
     std::string appID() const;
     unsigned surfaceID(const std::string &role) const;
     unsigned layerID() const;
-    const std::string& getWMLayerName();
     unsigned surfaceID() const;
     std::vector<unsigned> renderOrder() const;
     std::string role(unsigned surface) const;
@@ -71,7 +71,6 @@ class WMClient
   private:
     std::string id;
     unsigned layer;
-    std::string wm_layer_name;
     std::string main_role;
     std::string area;
     unsigned surface; // currently, main application has only one surface.
index 2a5f9bd..1cb54ee 100644 (file)
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef WM_LAYERS_H
-#define WM_LAYERS_H
+#ifndef WM_LAYER_HPP
+#define WM_LAYER_HPP
 
 #include <string>
 #include <vector>
@@ -83,4 +83,4 @@ class WMLayer
 
 } // namespace wm
 
-#endif // WM_LAYERS_H
+#endif // WM_LAYER_HPP