X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwindow_manager.cpp;h=dcaf636b66a6b47393def3861038a1199da9b263;hb=refs%2Fchanges%2F26%2F22726%2F1;hp=abd4552798103f5bee2c2e6f96651900d0c7ec20;hpb=ef03209fb7961d83daa30af74689acaa7a3bbbc2;p=apps%2Fagl-service-windowmanager.git diff --git a/src/window_manager.cpp b/src/window_manager.cpp index abd4552..dcaf636 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * Copyright (c) 2019 Konsulko Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -167,21 +168,25 @@ result WindowManager::api_request_surface(char const *appid, char const *dr if(!g_app_list.contains(str_id)) { - lid = this->lc->getNewLayerID(role); + 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("Designated role does not match any role, fallback is disabled"); - } + return Err("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 +229,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 +510,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 +712,28 @@ void WindowManager::processError(WMError error) this->processNextRequest(); } +unsigned WindowManager::generateLayerForClient(const string& role) +{ + string l_name; + unsigned lid = this->lc->getNewLayerID(role, &l_name); + 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; + } + } + + // TODO: remote layer name is fixed + this->lc->createNewLayer(lid, ("Remote" == l_name)); + + // add client into the db + return lid; +} + WMError WindowManager::setRequest(const string& appid, const string &role, const string &area, Task task, unsigned* req_num) { @@ -804,7 +839,6 @@ WMError WindowManager::startTransition(unsigned req_num) for (const auto &x : actions) { this->lc->visibilityChange(x); - x.client->emitActive(false); x.client->emitVisible(false); } this->lc->renderLayers(); @@ -841,8 +875,6 @@ WMError WindowManager::doEndDraw(unsigned req_num) return ret; } ret = this->lc->visibilityChange(act); - - act.client->emitActive((act.visible == VISIBLE)); act.client->emitVisible((act.visible == VISIBLE)); if (ret != WMError::SUCCESS)