From 0dcb9ae1f99cffcafac62a324f8f054cc212a880 Mon Sep 17 00:00:00 2001 From: Yuta Doi Date: Wed, 9 May 2018 17:15:42 +0900 Subject: Add conversion map role2app Change-Id: I1e194ecc9fb90ccb4c24e114ac1513ed19f0c0a3 Signed-off-by: Yuta Doi --- src/app.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src/app.cpp') 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 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(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"); -- cgit 1.2.3-korg