X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fapplist.cpp;h=a5ae9f000e56bfaa13632921f04fe85d391dbb8f;hb=0b3e861b1624eb9ff4b488724add8d01eb90bab2;hp=4e0dc1122ddf76f0ec9f2b88194d9ac30b5bde1c;hpb=6e2872d06857fdb6ecc76064cb80930e9a2635e4;p=apps%2Fagl-service-windowmanager.git diff --git a/src/applist.cpp b/src/applist.cpp index 4e0dc11..a5ae9f0 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -41,8 +41,8 @@ AppList::AppList() app2client(), current_req(1) { - app2client.reserve(kReserveClientSize); - req_list.reserve(kReserveReqSize); + this->app2client.reserve(kReserveClientSize); + this->req_list.reserve(kReserveReqSize); } AppList::~AppList() {} @@ -67,7 +67,7 @@ AppList::~AppList() {} */ void AppList::addClient(const std::string &appid, unsigned layer, unsigned surface, const std::string &role) { - std::lock_guard lock(mtx); + std::lock_guard lock(this->mtx); shared_ptr client = std::make_shared(appid, layer, surface, role); this->app2client[appid] = client; this->clientDump(); @@ -80,7 +80,7 @@ void AppList::addClient(const std::string &appid, unsigned layer, unsigned surfa */ void AppList::removeClient(const string &appid) { - std::lock_guard lock(mtx); + std::lock_guard lock(this->mtx); this->app2client.erase(appid); HMI_INFO("wm", "Remove client %s", appid.c_str()); } @@ -97,15 +97,22 @@ bool AppList::contains(const string &appid) const return (this->app2client.end() != result) ? true : false; } -void AppList::removeSurface(unsigned surface_id){ +/** + * Remove surface from client + * + * @param unsigned[in] surface id. + * @return None + */ +void AppList::removeSurface(unsigned surface){ // This function may be very slow - std::lock_guard lock(mtx); + std::lock_guard lock(this->mtx); bool ret = false; for (auto &x : this->app2client) { - ret = x.second->removeSurfaceIfExist(surface_id); + ret = x.second->removeSurfaceIfExist(surface); if(ret){ - HMI_DEBUG("wm", "remove surface %d from Client %s finish", surface_id, x.second->appID().c_str()); + HMI_DEBUG("wm", "remove surface %d from Client %s finish", + surface, x.second->appID().c_str()); break; } } @@ -133,15 +140,38 @@ shared_ptr AppList::lookUpClient(const string &appid) * * Returns the number of client stored in the list. * - * @param string[in] application id(key) - * @return WMClient object - * @attention Must call cantains to check appid is stored before this function. + * @param None + * @return The number of client */ int AppList::countClient() const { return this->app2client.size(); } +/** + * Get AppID with surface and role. + * + * Returns AppID if found. + * + * @param unsigned[in] surfaceID + * @param string[in] role + * @param bool[in,out] AppID is found or not + * @return AppID + * @attention If AppID is not found, param found will be false. + */ +string AppList::getAppID(unsigned surface, const string& role, bool* found) const +{ + *found = false; + for (const auto &x : this->app2client) + { + if(x.second->surfaceID(role) == surface){ + *found = true; + return x.second->appID(); + } + } + return string(""); +} + // =================== Request Date container API =================== /** @@ -196,9 +226,9 @@ unsigned AppList::getRequestNumber(const string &appid) const * @attention If the request number is different with curent request number, * it means the previous request is not finished. */ -unsigned AppList::addAllocateRequest(WMRequest req) +unsigned AppList::addRequest(WMRequest req) { - std::lock_guard lock(mtx); + std::lock_guard lock(this->mtx); if (this->req_list.size() == 0) { req.req_num = current_req; @@ -282,7 +312,7 @@ const vector &AppList::getActions(unsigned req_num, bool* found */ WMError AppList::setAction(unsigned req_num, const struct WMAction &action) { - std::lock_guard lock(mtx); + std::lock_guard lock(this->mtx); WMError result = WMError::FAIL; for (auto &x : this->req_list) { @@ -314,16 +344,16 @@ WMError AppList::setAction(unsigned req_num, const struct WMAction &action) * @param string[in] application id * @param string[in] role * @param string[in] area - * @param bool[in] the role should be visible or not. + * @param Task[in] the role should be visible or not. * @return WMError If request number is not valid, FAIL will be returned. * @attention This function set action with parameters, then caller doesn't need to create WMAction object. * If visible is true, it means app should be visible, so enddraw_finished parameter will be false. * otherwise (visible is false) app should be invisible. Then enddraw_finished param is set to true. * This function doesn't support actions for focus yet. */ -WMError AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, bool visible) +WMError AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, TaskVisible visible) { - std::lock_guard lock(mtx); + std::lock_guard lock(this->mtx); WMError result = WMError::FAIL; for (auto &x : req_list) { @@ -331,7 +361,8 @@ WMError AppList::setAction(unsigned req_num, const string &appid, const string & { continue; } - bool edraw_f = (visible) ? false : true; + // If visible task is not invisible, redraw is required -> true + bool edraw_f = (visible != TaskVisible::INVISIBLE) ? false : true; WMAction action{appid, role, area, visible, edraw_f}; x.sync_draw_req.push_back(action); @@ -356,7 +387,7 @@ WMError AppList::setAction(unsigned req_num, const string &appid, const string & */ bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const string &role) { - std::lock_guard lock(mtx); + std::lock_guard lock(this->mtx); bool result = false; for (auto &x : req_list) { @@ -370,6 +401,7 @@ bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const st { if (y.appid == appid && y.role == role) { + HMI_SEQ_INFO(req_num, "Role %s finish redraw", y.role.c_str()); y.end_draw_finished = true; result = true; } @@ -420,7 +452,7 @@ bool AppList::endDrawFullfilled(unsigned req_num) */ void AppList::removeRequest(unsigned req_num) { - std::lock_guard lock(mtx); + std::lock_guard lock(this->mtx); this->req_list.erase(remove_if(this->req_list.begin(), this->req_list.end(), [req_num](WMRequest x) { return x.req_num == req_num; @@ -435,7 +467,7 @@ void AppList::removeRequest(unsigned req_num) */ void AppList::next() { - std::lock_guard lock(mtx); + std::lock_guard lock(this->mtx); ++this->current_req; if (0 == this->current_req) { @@ -471,7 +503,7 @@ void AppList::reqDump() DUMP("current request : %d", current_req); for (const auto &x : req_list) { - DUMP("requested with : %d", x.req_num); + DUMP("requested : %d", x.req_num); DUMP("Trigger : (APPID :%s, ROLE :%s, AREA :%s, TASK: %d)", x.trigger.appid.c_str(), x.trigger.role.c_str(), @@ -481,13 +513,14 @@ void AppList::reqDump() for (const auto &y : x.sync_draw_req) { DUMP( - "Action : (APPID :%s, ROLE :%s, AREA :%s, END_DRAW_FINISHED: %d)", + "Action : (APPID :%s, ROLE :%s, AREA :%s, VISIBLE : %s, END_DRAW_FINISHED: %d)", y.appid.c_str(), y.role.c_str(), y.area.c_str(), + (y.visible == TaskVisible::INVISIBLE) ? "invisible" : "visible", y.end_draw_finished); } } - DUMP("======= req dump end =====\n"); + DUMP("======= req dump end ====="); } -} // namespace wm \ No newline at end of file +} // namespace wm