diff options
author | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-05-25 11:53:43 +0900 |
---|---|---|
committer | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-05-25 11:56:22 +0900 |
commit | 26557a931e330a3ce92d241dcb275a49b66afa10 (patch) | |
tree | 1aa0442defcf1ac0420de8521278ab5352edcb75 /src/app.cpp | |
parent | 0f4fc9687b78340eb99d9dc0d1890cc063735247 (diff) |
Delete label "role" for the API activateSurface and deactivateSurface
Change-Id: Ia59c0f3ad9d44e0836520abc50419d0be006acdf
Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
Diffstat (limited to 'src/app.cpp')
-rw-r--r-- | src/app.cpp | 69 |
1 files changed, 31 insertions, 38 deletions
diff --git a/src/app.cpp b/src/app.cpp index b168c64..cf10cef 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -269,32 +269,38 @@ void App::layout_commit() { this->display->flush(); } +const char* App::convertDrawingNameToRole(char const *drawing_name) { + const char* role; + + if (this->drawingname2role_.find(drawing_name) != this->drawingname2role_.end()) { + // drawing_name is old role. So convert to new role. + role = this->drawingname2role_[drawing_name].c_str(); + } + else { + // drawing_name is new role. + role = drawing_name; + } + HMI_DEBUG("wm", "drawing_name:%s -> role: %s", drawing_name, role); + + return role; +} + void App::allocateWindowResource(char const *event, char const *drawing_name, - char const *drawing_area, char const *role, - const reply_func &reply) { + char const *drawing_area, const reply_func &reply) { const char* new_role = nullptr; const char* new_area = nullptr; - if (0 == strcmp("activate", event)) { - // TODO: - // This process will be removed - // because the applications will specify role instead of drawing_name - { - if ((nullptr == role) || (0 == strcmp("", role))) { - HMI_DEBUG("wm", "Role is not specified, so get by using app name"); - new_role = this->app2role_[drawing_name].c_str(); - } - else { - new_role = role; - } - HMI_DEBUG("wm", "drawing_name:%s, new_role: %s", drawing_name, new_role); - } + // Convert old role to new role + if ((nullptr != drawing_name) && (0 != strcmp("", drawing_name))) { + new_role = this->convertDrawingNameToRole(drawing_name); + } + if (0 == strcmp("activate", event)) { // TODO: // This process will be removed // because the area "normal.full" and "normalfull" will be prohibited { - if (0 == strcmp("Restriction", drawing_name)) { + if (0 == strcmp("restriction", new_role)) { new_area = drawing_area; } else { @@ -319,19 +325,6 @@ void App::allocateWindowResource(char const *event, char const *drawing_name, } } else if (0 == strcmp("deactivate", event)) { - // TODO: - // This process will be removed - // because the applications will specify role instead of drawing_name - { - if ((nullptr == role) || (0 == strcmp("", role))) { - HMI_DEBUG("wm", "Role is not specified, so get by using app name"); - new_role = this->app2role_[drawing_name].c_str(); - } - else { - new_role = role; - } - HMI_DEBUG("wm", "drawing_name:%s, new_role: %s", drawing_name, new_role); - } new_area = ""; } @@ -641,8 +634,8 @@ void App::surface_removed(uint32_t surface_id) { } else { auto drawing_name = this->lookup_name(surface_id); if (drawing_name) { - this->allocateWindowResource("deactivate", drawing_name->c_str(), - nullptr, nullptr, + this->allocateWindowResource("deactivate", + drawing_name->c_str(), nullptr, [](const char*){}); } } @@ -754,7 +747,7 @@ result<int> App::api_request_surface(char const *drawing_name) { #endif // Set map of (role, surface_id) - std::string role = this->app2role_[std::string(drawing_name)]; + const char* role = this->convertDrawingNameToRole(drawing_name); this->role2surfaceid_[role] = id; // Set map of (role, app) @@ -958,8 +951,8 @@ void App::deactivate(std::string role) { void App::deactivate_main_surface() { this->layers.main_surface = -1; - this->allocateWindowResource("deactivate", this->layers.main_surface_name.c_str(), - nullptr, nullptr, + this->allocateWindowResource("deactivate", + this->layers.main_surface_name.c_str(), nullptr, [](const char*){}); } @@ -1200,12 +1193,12 @@ int App::loadAppDb() { } HMI_DEBUG("wm", "> role:%s", role); - this->app2role_[app] = std::string(role); + this->drawingname2role_[app] = std::string(role); } // Check - for(auto itr = this->app2role_.begin(); - itr != this->app2role_.end(); ++itr) { + for(auto itr = this->drawingname2role_.begin(); + itr != this->drawingname2role_.end(); ++itr) { HMI_DEBUG("wm", "app:%s role:%s", itr->first.c_str(), itr->second.c_str()); } |