diff options
author | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-05-09 17:15:42 +0900 |
---|---|---|
committer | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-05-09 17:15:42 +0900 |
commit | 0dcb9ae1f99cffcafac62a324f8f054cc212a880 (patch) | |
tree | 1ccf8a573689b52e59fc484bdd50a3c25d69ea9d | |
parent | e6d867b95a5e32ce5f50106b05020bd9888ae8a3 (diff) |
Add conversion map role2app
Change-Id: I1e194ecc9fb90ccb4c24e114ac1513ed19f0c0a3
Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
-rw-r--r-- | src/app.cpp | 21 | ||||
-rw-r--r-- | src/app.hpp | 5 |
2 files changed, 9 insertions, 17 deletions
diff --git a/src/app.cpp b/src/app.cpp index afd690f..b9338a9 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -673,6 +673,11 @@ result<int> App::api_request_surface(char const *drawing_name) { std::string role = this->app2role_[std::string(drawing_name)]; this->role2surfaceid_[role] = id; + // Set map of (role, app) + // If the new app which has the same role which is had by existing app is requested, + // the role is given to the new app. + this->role2app_[role] = std::string(drawing_name); + return Ok<int>(id); } @@ -853,7 +858,7 @@ void App::deactivate(int id) { } void App::deactivate(std::string role) { - std::string app = this->roleToApp(role); + std::string app = this->role2app_[role]; auto const &id = this->lookup_id(app.c_str()); if (!id) { HMI_ERROR("wm", "Surface does not exist"); @@ -1036,7 +1041,7 @@ void App::setSurfaceSize(const char* role, const char* area) { size.x, size.y, size.w, size.h); // Emit syncDraw event - const char* app = this->roleToApp(role).c_str(); + const char* app = this->role2app_[role].c_str(); this->emit_syncdraw(app, area, size.x, size.y, size.w, size.h); @@ -1044,18 +1049,6 @@ void App::setSurfaceSize(const char* role, const char* area) { this->enqueue_flushdraw(surface_id); } -std::string App::roleToApp(std::string role) { - HMI_DEBUG("wm", "Call"); - - for (auto itr = this->app2role_.begin(); - itr != this->app2role_.end(); itr++) { - if (role == itr->second) { - return itr->first; - } - } - return std::string("none"); -} - extern const char* kDefaultAppDb; int App::loadAppDb() { HMI_DEBUG("wm", "Call"); diff --git a/src/app.hpp b/src/app.hpp index 57ffee2..b7d6815 100644 --- a/src/app.hpp +++ b/src/app.hpp @@ -235,23 +235,22 @@ struct App { void surface_removed(uint32_t surface_id); private: -#if 1 // @@@@@ PolicyManager pm_; LayoutManager lm_; std::unordered_map<std::string, int> role2surfaceid_; std::unordered_map<std::string, std::string> app2role_; + std::unordered_map<std::string, std::string> role2app_; std::unordered_map<int, int> appid2role_; int allocateSurface(); void setSurfaceSize(const char* role, const char* area); - std::string roleToApp(std::string role); int loadAppDb(); #if 0 struct id_allocator app_id_alloc_; std::unordered_map<std::string, int> appname2appid_; #endif -#endif + optional<int> lookup_id(char const *name); optional<std::string> lookup_name(int id); |