X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fapplist.cpp;h=66289ea7671b32239b448fb9b5b042af0a47f1d7;hb=46d1ad85e8a4531dcb7dc9599f6c09554e2cdfbb;hp=06921c0043243bba5fa53e1e134744054e56e043;hpb=8e552f6dd6ee41b511b7153a8b729121cecca1b0;p=apps%2Fagl-service-windowmanager.git diff --git a/src/applist.cpp b/src/applist.cpp index 06921c0..66289ea 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -20,33 +20,56 @@ using std::shared_ptr; using std::string; -using std::unique_ptr; using std::vector; -namespace wm { - +namespace wm +{ AppList::AppList() : req_list(0), - client_list(0), - current_seq(1) -{} + app2client(0), + current_req(1) +{ +} -AppList::~AppList(){} +AppList::~AppList() {} -void AppList::addClient(const string &appid, const string &role){ +void AppList::addClient(const string &appid, const string &role) +{ shared_ptr client = std::make_shared(appid, role); - client_list[appid] = client; - client_dump(); + this->app2client[appid] = client; + this->clientDump(); } -void AppList::removeClient(const string &appid){ - client_list.erase(appid); +void AppList::addClient(const std::string &appid, unsigned layer, unsigned surface, const std::string &role) +{ + shared_ptr client = std::make_shared(appid, layer, surface, role); + this->app2client[appid] = client; + this->clientDump(); } -bool AppList::contains(const string &appid){ - auto result = client_list.find(appid); - return (client_list.end() != result) ? true : false; +void AppList::removeClient(const string &appid) +{ + this->app2client.erase(appid); +} + +bool AppList::contains(const string &appid) +{ + auto result = this->app2client.find(appid); + return (this->app2client.end() != result) ? true : false; +} + +void AppList::removeSurface(unsigned surface_id){ + // This function may be very slow + bool ret = false; + for (auto &x : this->app2client) + { + ret = x.second->removeSurfaceIfExist(surface_id); + if(ret){ + HMI_DEBUG("wm", "remove surface %d from Client %s finish", surface_id, x.second->appID().c_str()); + break; + } + } } /** @@ -55,25 +78,28 @@ bool AppList::contains(const string &appid){ * @param string[in] application id(key) * @return WMClient object */ -shared_ptr AppList::lookUpClient(const string &appid) +shared_ptr AppList::lookUpClient(const string &appid) { - return client_list.at(appid); + return this->app2client.at(appid); } int AppList::countClient() { - return client_list.size(); + return this->app2client.size(); } -unsigned AppList::currentSequenceNumber(){ - return current_seq; +unsigned AppList::currentSequenceNumber() +{ + return this->current_req; } // Is this function necessary ? -unsigned AppList::getSequenceNumber(const string &appid){ - for(const auto& x : req_list){ +unsigned AppList::getSequenceNumber(const string &appid) +{ + for (const auto &x : this->req_list) + { // Since app will not request twice and more, comparing appid is enough? - if( (x.trigger.appid == appid)) + if ((x.trigger.appid == appid)) { return x.seq_num; } @@ -81,50 +107,83 @@ unsigned AppList::getSequenceNumber(const string &appid){ return 0; } -unsigned AppList::addAllocateRequest(WMRequest req){ - if(req_list.size() == 0){ - req.seq_num = current_seq; +unsigned AppList::addAllocateRequest(WMRequest req) +{ + if (this->req_list.size() == 0) + { + req.seq_num = current_req; } - else{ - HMI_SEQ_DEBUG(current_seq, "real: %d", req_list.back().seq_num + 1); - req.seq_num = req_list.back().seq_num + 1; + else + { + HMI_SEQ_DEBUG(this->current_req, "add: %d", this->req_list.back().seq_num + 1); + req.seq_num = this->req_list.back().seq_num + 1; } - req_list.push_back(req); + this->req_list.push_back(req); return req.seq_num; // return 1; if you test time_expire } -bool AppList::requestFinished(){ - return req_list.empty(); +bool AppList::requestFinished() +{ + return this->req_list.empty(); } -struct WMTrigger AppList::getRequest(unsigned request_seq){ - for(auto& x : req_list){ - if (request_seq == x.seq_num) +struct WMTrigger AppList::getRequest(unsigned req_num) +{ + for (auto &x : this->req_list) + { + if (req_num == x.seq_num) { return x.trigger; } } } -const vector& AppList::getActions(unsigned request_seq){ - for (auto &x : req_list) +const vector &AppList::getActions(unsigned req_num) +{ + for (auto &x : this->req_list) { - if (request_seq == x.seq_num) + if (req_num == x.seq_num) { return x.sync_draw_req; } } } -bool AppList::setAction(unsigned request_seq, const string &appid, const string &role, const string &area){ +bool AppList::setAction(unsigned req_num, const struct WMAction &action) +{ + bool result = false; + for (auto &x : this->req_list) + { + if (req_num != x.seq_num) + { + continue; + } + x.sync_draw_req.push_back(action); + result = true; + break; + } + + return result; +} + +/** + * Note: + * This function set action with parameters. + * if visible is true, it means app should be visible, so enddraw_finished parameter should 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. + */ +bool AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, bool visible) +{ bool result = false; - for (auto& x : req_list) + for (auto &x : req_list) { - if (request_seq != x.seq_num) + if (req_num != x.seq_num) { continue; } - WMAction action{appid, role, area, false}; + bool edraw_f = (visible) ? false : true; + WMAction action{appid, role, area, visible, edraw_f}; x.sync_draw_req.push_back(action); result = true; @@ -133,17 +192,19 @@ bool AppList::setAction(unsigned request_seq, const string &appid, const string return result; } -bool AppList::setEndDrawFinished(unsigned request_seq, const string &appid, const string &role){ +bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const string &role) +{ bool result = false; - for (auto& x : req_list) + for (auto &x : req_list) { - if (request_seq < x.seq_num) + if (req_num < x.seq_num) { break; } - if (request_seq == x.seq_num) + if (req_num == x.seq_num) { - for(auto& y : x.sync_draw_req){ + for (auto &y : x.sync_draw_req) + { if (y.appid == appid && y.role == role) { y.end_draw_finished = true; @@ -152,7 +213,7 @@ bool AppList::setEndDrawFinished(unsigned request_seq, const string &appid, cons } } } - req_dump(); + this->reqDump(); return result; } @@ -161,18 +222,23 @@ bool AppList::setEndDrawFinished(unsigned request_seq, const string &appid, cons * @param unsigned sequence_num * @return true if all action is set. */ -bool AppList::endDrawFullfilled(unsigned request_seq){ +bool AppList::endDrawFullfilled(unsigned req_num) +{ bool result = false; - for (const auto& x : req_list) + for (const auto &x : req_list) { - if(request_seq < x.seq_num){ + if (req_num < x.seq_num) + { break; } - if(request_seq == x.seq_num){ + if (req_num == x.seq_num) + { result = true; - for(const auto& y : x.sync_draw_req){ + for (const auto &y : x.sync_draw_req) + { result &= y.end_draw_finished; - if(!result){ + if (!result) + { break; } } @@ -181,39 +247,45 @@ bool AppList::endDrawFullfilled(unsigned request_seq){ return result; } -void AppList::removeRequest(unsigned req_seq){ - req_list.erase(remove_if(req_list.begin(), req_list.end(), - [req_seq](WMRequest x) { - return x.seq_num == req_seq; - })); +void AppList::removeRequest(unsigned req_seq) +{ + this->req_list.erase(remove_if(this->req_list.begin(), this->req_list.end(), + [req_seq](WMRequest x) { + return x.seq_num == req_seq; + })); } -void AppList::next(){ - ++this->current_seq; - if (0 == this->current_seq) +void AppList::next() +{ + ++this->current_req; + if (0 == this->current_req) { - this->current_seq = 1; + this->current_req = 1; } } -bool AppList::haveRequest(){ - return !req_list.empty(); +bool AppList::haveRequest() +{ + return !this->req_list.empty(); } -void AppList::client_dump(){ +void AppList::clientDump() +{ DUMP("======= client dump ====="); - for(const auto& x : client_list){ - const auto& y = x.second; - DUMP("APPID : %s", y->appID().c_str()); + for (const auto &x : this->app2client) + { + const auto &y = x.second; + y->dumpInfo(); } DUMP("======= client dump end====="); } -void AppList::req_dump() +void AppList::reqDump() { DUMP("======= req dump ====="); - DUMP("current request : %d", current_seq); - for(const auto& x : req_list){ + DUMP("current request : %d", current_req); + for (const auto &x : req_list) + { DUMP("requested with : %d", x.seq_num); DUMP("Trigger : (APPID :%s, ROLE :%s, AREA :%s, TASK: %d)", x.trigger.appid.c_str(), @@ -221,7 +293,8 @@ void AppList::req_dump() x.trigger.area.c_str(), x.trigger.task); - for (const auto& y : x.sync_draw_req){ + for (const auto &y : x.sync_draw_req) + { DUMP( "Action : (APPID :%s, ROLE :%s, AREA :%s, END_DRAW_FINISHED: %d)", y.appid.c_str(), @@ -232,4 +305,4 @@ void AppList::req_dump() } DUMP("======= req dump end =====\n"); } -} \ No newline at end of file +} // namespace wm \ No newline at end of file