X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fapplist.cpp;h=b5c1681f7239a04a895e11c6287452a086514e6b;hb=17dd59f6fbc3deead5ce85006fb79aa9845bbdb4;hp=462a0d81ce40d34a43622f5b1ec36f171d1dc95e;hpb=9cfdd8937209e3e47b551e7a188add100cbae2e7;p=apps%2Fagl-service-windowmanager.git diff --git a/src/applist.cpp b/src/applist.cpp index 462a0d8..b5c1681 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -32,8 +32,6 @@ AppList::AppList() { } -AppList::~AppList() {} - void AppList::addClient(const string &appid, const string &role) { shared_ptr client = std::make_shared(appid, role); @@ -53,7 +51,7 @@ void AppList::removeClient(const string &appid) this->app2client.erase(appid); } -bool AppList::contains(const string &appid) +bool AppList::contains(const string &appid) const { auto result = this->app2client.find(appid); return (this->app2client.end() != result) ? true : false; @@ -83,18 +81,75 @@ shared_ptr AppList::lookUpClient(const string &appid) return this->app2client.at(appid); } -int AppList::countClient() +int AppList::countClient() const { return this->app2client.size(); } -unsigned AppList::currentRequestNumber() +unsigned AppList::currentRequestNumber() const { return this->current_req; } -// Is this function necessary ? -unsigned AppList::getRequestNumber(const string &appid) +WMError AppList::popFloatingSurface(unsigned pid, unsigned *surface) +{ + WMError ret = WMError::NO_ENTRY; + + for (auto itr = this->floating_surfaces.begin(); itr != this->floating_surfaces.end(); ++itr) + { + if(pid == itr->pid){ + *surface = itr->surface_id; + itr = this->floating_surfaces.erase(itr); + ret = WMError::SUCCESS; + HMI_DEBUG("wm", "Erase surface %d", *surface); + break; + } + } + return ret; +} + +WMError AppList::popFloatingSurface(const std::string &appid, unsigned *surface) +{ + HMI_ERROR("wm", "This function is not implemented"); + return WMError::SUCCESS; +} + +void AppList::addFloatingClient(const std::string &appid, unsigned layer, const std::string &role) +{ +} + +void AppList::addFloatingSurface(unsigned surface, unsigned pid) +{ + struct FloatingSurface fsurface{surface, pid}; + this->floating_surfaces.push_back(fsurface); +} + +void AppList::removeFloatingSurface(unsigned surface) +{ + for (auto itr = this->floating_surfaces.begin(); itr != this->floating_surfaces.end(); ++itr) + { + if (surface == itr->surface_id) + { + HMI_DEBUG("wm", "Erase surface %d", itr->surface_id); + itr = this->floating_surfaces.erase(itr); + break; + } + } +} + +WMError AppList::appendRole(const std::string &id, const std::string &role, unsigned surface) +{ + WMError wm_err = WMError::NO_ENTRY; + if (this->contains(id)) + { + auto x = this->lookUpClient(id); + x->addSurface(role, surface); + wm_err = WMError::SUCCESS; + } + return wm_err; +} + +unsigned AppList::getRequestNumber(const string &appid) const { for (const auto &x : this->req_list) { @@ -122,14 +177,9 @@ unsigned AppList::addAllocateRequest(WMRequest req) return req.req_num; // return 1; if you test time_expire } -bool AppList::requestFinished() -{ - return this->req_list.empty(); -} - struct WMTrigger AppList::getRequest(unsigned req_num) { - for (auto &x : this->req_list) + for (const auto &x : this->req_list) { if (req_num == x.req_num) { @@ -149,9 +199,9 @@ const vector &AppList::getActions(unsigned req_num) } } -bool AppList::setAction(unsigned req_num, const struct WMAction &action) +WMError AppList::setAction(unsigned req_num, const struct WMAction &action) { - bool result = false; + WMError result = WMError::FAIL; for (auto &x : this->req_list) { if (req_num != x.req_num) @@ -159,7 +209,7 @@ bool AppList::setAction(unsigned req_num, const struct WMAction &action) continue; } x.sync_draw_req.push_back(action); - result = true; + result = WMError::SUCCESS; break; } @@ -173,9 +223,9 @@ bool AppList::setAction(unsigned req_num, const struct WMAction &action) * 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) +WMError AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, bool visible) { - bool result = false; + WMError result = WMError::NOT_REGISTERED; for (auto &x : req_list) { if (req_num != x.req_num) @@ -186,7 +236,7 @@ bool AppList::setAction(unsigned req_num, const string &appid, const string &rol WMAction action{appid, role, area, visible, edraw_f}; x.sync_draw_req.push_back(action); - result = true; + result = WMError::SUCCESS; break; } return result; @@ -269,7 +319,7 @@ void AppList::next() } } -bool AppList::haveRequest() +bool AppList::haveRequest() const { return !this->req_list.empty(); }