aboutsummaryrefslogtreecommitdiffstats
path: root/src/window_manager.cpp
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2019-03-14 13:53:46 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2019-03-14 13:55:39 +0900
commit2586b2d3138c0f6b6735eb77cf1ebcce47ca1a2d (patch)
tree9bc5d3a3c02d58971a9cfaac488810ff745737b5 /src/window_manager.cpp
parenta0fa6394c0d8b7997343d6f2a44d9c2868f4be5f (diff)
Fix xdg-runcher doesn't show upflounder_6.0.5flounder/6.0.56.0.5flounder
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". This patch is backport of master. Bug-AGL: SPEC-2218 Change-Id: I448d84889a24647d4e620c4b8f041087e856da32 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 965c60d..33f19ee 100644
--- a/src/window_manager.cpp
+++ b/src/window_manager.cpp
@@ -174,21 +174,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, drawing_name);
}
+ 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(drawing_name);
+ }
// generate surface ID for ivi-shell application
auto rname = this->id_alloc.lookup(role);
@@ -238,21 +242,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, drawing_name);
}
+ 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(drawing_name);
+ }
auto rname = this->id_alloc.lookup(role);
@@ -436,11 +444,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;
}
@@ -637,6 +649,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)
{