aboutsummaryrefslogtreecommitdiffstats
path: root/src/window_manager.cpp
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2019-03-13 18:02:37 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2019-03-14 13:01:46 +0900
commit464f20cc2a960052233c4e2cbc2bd7dd3876b7f7 (patch)
tree6a5f93a935ac932c7188081a5854156f14239c24 /src/window_manager.cpp
parentd4b18f9152860b4fd8746e5098a75ad56dba1c7f (diff)
Fix xdg-runcher doesn't show up
xdg-runcher calls "subscribe" before requestSurface, then windowmanager reject it because WMClient object is not created yet. This patch changes to register WMClient if it is not created when App calls "subscribe". Application doesn't need to care about the order of "requestSurface" and "subscribe". Bug-AGL: SPEC-2218 Change-Id: Ia82ff939dfdb2bbfd377bd50fd3d4b844451cd3b Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
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)
{