Rename class name LayerManager to LayerControl
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Wed, 22 Aug 2018 00:53:15 +0000 (09:53 +0900)
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>
Wed, 22 Aug 2018 00:53:15 +0000 (09:53 +0900)
Change-Id: I60315e2a71af60b2a8e7576bc4313983330b5b3d
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
src/CMakeLists.txt
src/window_manager.cpp
src/window_manager.hpp
src/wm_layer_control.cpp [moved from src/layout_manager.cpp with 70% similarity]
src/wm_layer_control.hpp [moved from src/layout_manager.hpp with 89% similarity]

index b1597b7..192e2b2 100644 (file)
@@ -40,7 +40,7 @@ add_library(${TARGETS_WM} MODULE
    request.cpp
    pm_wrapper.cpp
    wm_layer.cpp
-   layout_manager.cpp)
+   wm_layer_control.cpp)
 
 target_include_directories(${TARGETS_WM}
     PRIVATE
index bb8b073..22f411a 100644 (file)
@@ -136,7 +136,7 @@ WindowManager::WindowManager(wl::display *d)
     {
         lm_setting_path += "/etc/layers_setting.json";
     }
-    this->lm = std::make_shared<LayoutManager>(lm_setting_path);
+    this->lm = std::make_shared<LayerControl>(lm_setting_path);
 
 /*     try
     {
@@ -249,12 +249,14 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
     const char *role = this->convertRoleOldToNew(drawing_name);
 
     auto lid = this->layers.get_layer_id(string(role));
-    if (!lid)
+    unsigned l_id = this->lm->getNewLayerID(role);
+    if (l_id != 0)
     {
         /**
        * register drawing_name as fallback and make it displayed.
        */
         lid = this->layers.get_layer_id(string("fallback"));
+        l_id = this->lm->getNewLayerID("fallback");
         HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role);
         if (!lid)
         {
@@ -262,30 +264,41 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
         }
     }
 
-    auto rname = this->lookup_id(role);
-    if (!rname)
-    {
+    // generate surface ID for ivi-shell application
+
+    // auto rname = this->lookup_id(role);
+    // if (!rname)
+    // {
         // name does not exist yet, allocate surface id...
         auto id = int(this->id_alloc.generate_id(role));
-        this->layers.add_surface(id, *lid);
+        // this->layers.add_surface(id, *lid);
 
         // set the main_surface[_name] here and now
-        if (!this->layers.main_surface_name.empty() &&
-            this->layers.main_surface_name == drawing_name)
-        {
-            this->layers.main_surface = id;
-            HMI_DEBUG("wm", "Set main_surface id to %u", id);
-        }
+        // if (!this->layers.main_surface_name.empty() &&
+        //     this->layers.main_surface_name == drawing_name)
+        // {
+        //     this->layers.main_surface = id;
+        //     HMI_DEBUG("wm", "Set main_surface id to %u", id);
+        // }
 
         // add client into the db
         string appid_str(appid);
-        g_app_list.addClient(appid_str, *lid, id, string(role));
+        if(g_app_list.contains(appid_str))
+        {
+            // add surface into app
+            auto client = g_app_list.lookUpClient(appid_str);
+            // client.addSurface(id);
+        }
+        else
+        {
+            g_app_list.addClient(appid_str, l_id, id, string(role));
+        }
 
         // Set role map of (new, old)
         this->rolenew2old[role] = string(drawing_name);
 
         return Ok<int>(id);
-    }
+    // }
 
     // Check currently registered drawing names if it is already there.
     return Err<int>("Surface already present");
index d77d23a..3088111 100644 (file)
@@ -29,7 +29,7 @@
 #include "hmi-debug.h"
 #include "request.hpp"
 #include "wm_error.hpp"
-#include "layout_manager.hpp"
+#include "wm_layer_control.hpp"
 
 struct json_object;
 
@@ -281,7 +281,7 @@ class WindowManager
     std::unordered_map<std::string, struct compositor::rect> area2size;
     std::unordered_map<std::string, std::string> roleold2new;
     std::unordered_map<std::string, std::string> rolenew2old;
-    std::shared_ptr<LayoutManager> lm;
+    std::shared_ptr<LayerControl> lm;
     PMWrapper pmw;
 
     static const char* kDefaultOldRoleDb;
similarity index 70%
rename from src/layout_manager.cpp
rename to src/wm_layer_control.cpp
index 66de5c3..0d8c924 100644 (file)
 \r
 #include <assert.h>\r
 #include "layers.hpp"\r
-#include "layout_manager.hpp"\r
+#include "wm_layer_control.hpp"\r
 \r
 using std::string;\r
 \r
 namespace wm {\r
 \r
-LayoutManager::LayoutManager(const string& path) : wm_layers()\r
+LayerControl::LayerControl(const string& path) : wm_layers()\r
 {\r
     WMError ret = this->load(path);\r
     assert(ret == WMError::SUCCESS);\r
 }\r
 \r
-LayoutManager::~LayoutManager()\r
+LayerControl::~LayerControl()\r
 {}\r
 \r
-unsigned LayoutManager::getNewLayerID(const string& role)\r
+unsigned LayerControl::getNewLayerID(const string& role)\r
 {\r
     unsigned ret = 0;\r
     for(const auto& l: this->wm_layers)\r
@@ -45,16 +45,16 @@ unsigned LayoutManager::getNewLayerID(const string& role)
     return ret;\r
 }\r
 \r
-WMError LayoutManager::updateLayer(WMLayer& wm_layer)\r
+WMError LayerControl::updateLayer(WMLayer& wm_layer)\r
 {\r
     return WMError::SUCCESS;\r
 }\r
 \r
-void LayoutManager::commitChange() {}\r
+void LayerControl::commitChange() {}\r
 \r
-void LayoutManager::undoUpdate() {}\r
+void LayerControl::undoUpdate() {}\r
 \r
-WMError LayoutManager::load(const string &path)\r
+WMError LayerControl::load(const string &path)\r
 {\r
     return WMError::SUCCESS;\r
 }\r
similarity index 89%
rename from src/layout_manager.hpp
rename to src/wm_layer_control.hpp
index 34e8e59..dacb557 100644 (file)
 \r
 namespace wm {\r
 \r
-class LayoutManager\r
+class LayerControl\r
 {\r
   public:\r
-    explicit LayoutManager(const std::string& path);\r
-    ~LayoutManager();\r
+    explicit LayerControl(const std::string& path);\r
+    ~LayerControl();\r
     unsigned getNewLayerID(const std::string& role);\r
     // void setRenderOrder(const std::vector<unsigned> layer_render_order);\r
     // std::vector<unsigned> getAllRenderOrder();\r