aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.cpp')
-rw-r--r--src/app.cpp69
1 files changed, 31 insertions, 38 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 18bc15e..e9af748 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)
@@ -994,8 +987,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*){});
}
@@ -1236,12 +1229,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());
}