summaryrefslogtreecommitdiffstats
path: root/src/window_manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/window_manager.cpp')
-rw-r--r--src/window_manager.cpp72
1 files changed, 51 insertions, 21 deletions
diff --git a/src/window_manager.cpp b/src/window_manager.cpp
index 4fcab5f..1e3a926 100644
--- a/src/window_manager.cpp
+++ b/src/window_manager.cpp
@@ -167,21 +167,25 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
if(!g_app_list.contains(str_id))
{
- lid = this->lc->getNewLayerID(role);
+ unsigned lid = this->generateLayerForClient(role);
if (lid == 0)
{
- // register drawing_name as fallback and make it displayed.
- lid = this->lc->getNewLayerID(string("fallback"));
- HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role.c_str());
- if (lid == 0)
- {
- return Err<int>("Designated role does not match any role, fallback is disabled");
- }
+ return Err<int>("Designated role does not match any role, fallback is disabled");
}
- this->lc->createNewLayer(lid);
// add client into the db
g_app_list.addClient(str_id, lid, role);
}
+ else
+ {
+ // This case occurs when an client calls "subscribe" before request_surface.
+ // Then application doesn't have layer and role yet.
+ auto client = g_app_list.lookUpClient(str_id);
+ if(client->layerID() == 0)
+ {
+ client->setLayerID(this->generateLayerForClient(role));
+ }
+ client->setRole(role);
+ }
// generate surface ID for ivi-shell application
auto rname = this->id_alloc.lookup(role);
@@ -224,21 +228,25 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
if(!g_app_list.contains(str_id))
{
- unsigned l_id = this->lc->getNewLayerID(role);
+ unsigned l_id = this->generateLayerForClient(role);
if (l_id == 0)
{
- // register drawing_name as fallback and make it displayed.
- l_id = this->lc->getNewLayerID("fallback");
- HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role.c_str());
- if (l_id == 0)
- {
- return "Designated role does not match any role, fallback is disabled";
- }
+ return "Designated role does not match any role, fallback is disabled";
}
- this->lc->createNewLayer(l_id);
// add client into the db
g_app_list.addClient(str_id, l_id, role);
}
+ else
+ {
+ // This case occurs when an client calls "subscribe" before request_surface.
+ // Then application doesn't have layer and role yet.
+ auto client = g_app_list.lookUpClient(str_id);
+ if(client->layerID() == 0)
+ {
+ client->setLayerID(this->generateLayerForClient(role));
+ }
+ client->setRole(role);
+ }
auto rname = this->id_alloc.lookup(role);
@@ -501,11 +509,15 @@ bool WindowManager::api_subscribe(afb_req_t req, EventType event_id)
{
string id = appid;
free(appid);
- auto client = g_app_list.lookUpClient(id);
- if(client != nullptr)
+ if(!g_app_list.contains(id))
{
- ret = client->subscribe(req, kListEventName[event_id]);
+ g_app_list.addClient(id);
}
+ g_app_list.lookUpClient(id)->subscribe(req, kListEventName[event_id]);
+ }
+ else
+ {
+ HMI_ERROR("appid is not set");
}
return ret;
}
@@ -699,6 +711,24 @@ void WindowManager::processError(WMError error)
this->processNextRequest();
}
+unsigned WindowManager::generateLayerForClient(const string& role)
+{
+ unsigned lid = this->lc->getNewLayerID(role);
+ if (lid == 0)
+ {
+ // register drawing_name as fallback and make it displayed.
+ lid = this->lc->getNewLayerID(string("fallback"));
+ HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role.c_str());
+ if (lid == 0)
+ {
+ return lid;
+ }
+ }
+ this->lc->createNewLayer(lid);
+ // add client into the db
+ return lid;
+}
+
WMError WindowManager::setRequest(const string& appid, const string &role, const string &area,
Task task, unsigned* req_num)
{