From c2fdab514796f8f14cc59cf403a0fc557ce3c8f8 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Wed, 22 Aug 2018 09:53:15 +0900 Subject: Rename class name LayerManager to LayerControl Change-Id: I60315e2a71af60b2a8e7576bc4313983330b5b3d Signed-off-by: Kazumasa Mitsunari --- src/CMakeLists.txt | 2 +- src/layout_manager.cpp | 62 ------------------------------------------------ src/layout_manager.hpp | 44 ---------------------------------- src/window_manager.cpp | 41 +++++++++++++++++++++----------- src/window_manager.hpp | 4 ++-- src/wm_layer_control.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ src/wm_layer_control.hpp | 44 ++++++++++++++++++++++++++++++++++ 7 files changed, 136 insertions(+), 123 deletions(-) delete mode 100644 src/layout_manager.cpp delete mode 100644 src/layout_manager.hpp create mode 100644 src/wm_layer_control.cpp create mode 100644 src/wm_layer_control.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b1597b7..192e2b2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/layout_manager.cpp b/src/layout_manager.cpp deleted file mode 100644 index 66de5c3..0000000 --- a/src/layout_manager.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2017 TOYOTA MOTOR CORPORATION - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "layers.hpp" -#include "layout_manager.hpp" - -using std::string; - -namespace wm { - -LayoutManager::LayoutManager(const string& path) : wm_layers() -{ - WMError ret = this->load(path); - assert(ret == WMError::SUCCESS); -} - -LayoutManager::~LayoutManager() -{} - -unsigned LayoutManager::getNewLayerID(const string& role) -{ - unsigned ret = 0; - for(const auto& l: this->wm_layers) - { - ret = l->getNewLayerID(role); - if(ret != 0) - { - break; - } - } - return ret; -} - -WMError LayoutManager::updateLayer(WMLayer& wm_layer) -{ - return WMError::SUCCESS; -} - -void LayoutManager::commitChange() {} - -void LayoutManager::undoUpdate() {} - -WMError LayoutManager::load(const string &path) -{ - return WMError::SUCCESS; -} - -} // namespace wm \ No newline at end of file diff --git a/src/layout_manager.hpp b/src/layout_manager.hpp deleted file mode 100644 index 34e8e59..0000000 --- a/src/layout_manager.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017 TOYOTA MOTOR CORPORATION - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "wm_error.hpp" -#include "wm_layer.hpp" - -namespace wm { - -class LayoutManager -{ - public: - explicit LayoutManager(const std::string& path); - ~LayoutManager(); - unsigned getNewLayerID(const std::string& role); - // void setRenderOrder(const std::vector layer_render_order); - // std::vector getAllRenderOrder(); - // std::vector>& getAllLayers(); - // std::vector getRenderOrder(const std::string& layer_name); - WMError updateLayer(WMLayer& wm_layer); - void commitChange(); - void undoUpdate(); - private: - WMError load(const std::string& path); - std::vector> wm_layers; -}; - -} // namespace wm \ No newline at end of file diff --git a/src/window_manager.cpp b/src/window_manager.cpp index bb8b073..22f411a 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -136,7 +136,7 @@ WindowManager::WindowManager(wl::display *d) { lm_setting_path += "/etc/layers_setting.json"; } - this->lm = std::make_shared(lm_setting_path); + this->lm = std::make_shared(lm_setting_path); /* try { @@ -249,12 +249,14 @@ result 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 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(id); - } + // } // Check currently registered drawing names if it is already there. return Err("Surface already present"); diff --git a/src/window_manager.hpp b/src/window_manager.hpp index d77d23a..3088111 100644 --- a/src/window_manager.hpp +++ b/src/window_manager.hpp @@ -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 area2size; std::unordered_map roleold2new; std::unordered_map rolenew2old; - std::shared_ptr lm; + std::shared_ptr lm; PMWrapper pmw; static const char* kDefaultOldRoleDb; diff --git a/src/wm_layer_control.cpp b/src/wm_layer_control.cpp new file mode 100644 index 0000000..0d8c924 --- /dev/null +++ b/src/wm_layer_control.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "layers.hpp" +#include "wm_layer_control.hpp" + +using std::string; + +namespace wm { + +LayerControl::LayerControl(const string& path) : wm_layers() +{ + WMError ret = this->load(path); + assert(ret == WMError::SUCCESS); +} + +LayerControl::~LayerControl() +{} + +unsigned LayerControl::getNewLayerID(const string& role) +{ + unsigned ret = 0; + for(const auto& l: this->wm_layers) + { + ret = l->getNewLayerID(role); + if(ret != 0) + { + break; + } + } + return ret; +} + +WMError LayerControl::updateLayer(WMLayer& wm_layer) +{ + return WMError::SUCCESS; +} + +void LayerControl::commitChange() {} + +void LayerControl::undoUpdate() {} + +WMError LayerControl::load(const string &path) +{ + return WMError::SUCCESS; +} + +} // namespace wm \ No newline at end of file diff --git a/src/wm_layer_control.hpp b/src/wm_layer_control.hpp new file mode 100644 index 0000000..dacb557 --- /dev/null +++ b/src/wm_layer_control.hpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include "wm_error.hpp" +#include "wm_layer.hpp" + +namespace wm { + +class LayerControl +{ + public: + explicit LayerControl(const std::string& path); + ~LayerControl(); + unsigned getNewLayerID(const std::string& role); + // void setRenderOrder(const std::vector layer_render_order); + // std::vector getAllRenderOrder(); + // std::vector>& getAllLayers(); + // std::vector getRenderOrder(const std::string& layer_name); + WMError updateLayer(WMLayer& wm_layer); + void commitChange(); + void undoUpdate(); + private: + WMError load(const std::string& path); + std::vector> wm_layers; +}; + +} // namespace wm \ No newline at end of file -- cgit 1.2.3-korg