From 915faae5e2901f2112a680586582a282c44dc401 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Fri, 31 Aug 2018 18:35:31 +0900 Subject: Bug Fix : wm_layer Change-Id: I6048e6e5b98fcea167e5a0bc03e7f0e9761ff8af Signed-off-by: Kazumasa Mitsunari --- src/wm_layer.cpp | 19 ++++++++++++++++--- src/wm_layer_control.cpp | 7 ++++--- src/wm_layer_control.hpp | 4 ++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/wm_layer.cpp b/src/wm_layer.cpp index d74418a..7f8dbd9 100644 --- a/src/wm_layer.cpp +++ b/src/wm_layer.cpp @@ -26,6 +26,8 @@ using std::string; using std::vector; using std::unordered_map; +#define BG_LAYER_NAME "BackGroundLayer" + namespace wm { @@ -88,7 +90,7 @@ WMLayer::WMLayer(json_object* j) : before_state(), state() this->id_begin = static_cast(jh::getIntFromJson(j, "id_range_begin")); this->id_end = static_cast(jh::getIntFromJson(j, "id_range_end")); - if (name.size() == 0 || type || this->id_begin == 0 || this->id_end == 0) + if (name.size() == 0 || !type) { HMI_ERROR("Parse Error!!"); exit(1); @@ -109,7 +111,15 @@ unsigned WMLayer::getNewLayerID(const string& role) // generate new layer id; if(this->hasRole(role)) { - ret = this->id_list.back() + 1; + if(this->id_list.size() == 0) + { + ret = this->idBegin(); + this->id_list.push_back(ret); + } + else + { + ret = this->id_list.back() + 1; + } HMI_INFO("Generate new id: %d", ret); } else @@ -181,10 +191,13 @@ bool WMLayer::hasLayerID(unsigned id) bool WMLayer::hasRole(const string& role) { + // TODO : use virtual to avoid compare + if(this->name == BG_LAYER_NAME) + return false; auto re = std::regex(this->role_list); if (std::regex_match(role, re)) { - HMI_DEBUG("role %s matches layer %d", role.c_str(), this->name.c_str()); + HMI_DEBUG("role %s matches layer %s", role.c_str(), this->name.c_str()); return true; } return false; diff --git a/src/wm_layer_control.cpp b/src/wm_layer_control.cpp index 86616e8..325598d 100644 --- a/src/wm_layer_control.cpp +++ b/src/wm_layer_control.cpp @@ -69,10 +69,11 @@ LayerControl::LayerControl(const std::string& root) WMError LayerControl::init(const LayerControlCallbacks& cb) { - ilmErrorTypes rc = ilm_init(); + HMI_DEBUG("Initialize of ilm library and display"); t_ilm_uint num = 0; t_ilm_uint *ids; int cnt = 0; + ilmErrorTypes rc = ilm_init(); while (rc != ILM_SUCCESS) { @@ -84,7 +85,7 @@ WMError LayerControl::init(const LayerControlCallbacks& cb) } HMI_ERROR("Wait to start weston ..."); sleep(1); - ilm_init(); + rc = ilm_init(); } if(rc != ILM_SUCCESS) goto lc_init_error; @@ -164,7 +165,7 @@ void LayerControl::setupArea(double scaling) i.second.w = static_cast(scaling * i.second.w + 0.5); i.second.h = static_cast(scaling * i.second.h + 0.5); - HMI_DEBUG("wm:lm", "area:%s size(after) : x:%d y:%d w:%d h:%d", + HMI_DEBUG("area:%s size(after) : x:%d y:%d w:%d h:%d", i.first.c_str(), i.second.x, i.second.y, i.second.w, i.second.h); } } diff --git a/src/wm_layer_control.hpp b/src/wm_layer_control.hpp index 7752fc4..f0bc175 100644 --- a/src/wm_layer_control.hpp +++ b/src/wm_layer_control.hpp @@ -40,11 +40,11 @@ class Screen { class LayerControlCallbacks { public: LayerControlCallbacks() {}; - virtual ~LayerControlCallbacks() = default; + ~LayerControlCallbacks() = default; LayerControlCallbacks(const LayerControlCallbacks &obj) = default; // callback functions - virtual void test(unsigned i) { HMI_DEBUG("test %d", i); } + void test(unsigned i) { HMI_DEBUG("test %d", i); } std::function surfaceCreated; /* std::function surfaceDestroyed; std::function layerCreated; -- cgit 1.2.3-korg